mirror of
https://github.com/hyprwm/hypridle.git
synced 2025-12-20 17:10:02 +01:00
* feat: support `source` option for additional config files * fix: prevent circular dependency
19 lines
No EOL
674 B
C++
19 lines
No EOL
674 B
C++
#include <filesystem>
|
|
|
|
#include "MiscFunctions.hpp"
|
|
|
|
std::string absolutePath(const std::string& rawpath, const std::string& currentDir) {
|
|
std::filesystem::path path(rawpath);
|
|
|
|
// Handling where rawpath starts with '~'
|
|
if (!rawpath.empty() && rawpath[0] == '~') {
|
|
static const char* const ENVHOME = getenv("HOME");
|
|
path = std::filesystem::path(ENVHOME) / path.relative_path().string().substr(2);
|
|
}
|
|
|
|
// Handling e.g. ./, ../
|
|
if (path.is_relative())
|
|
return std::filesystem::weakly_canonical(std::filesystem::path(currentDir) / path);
|
|
else
|
|
return std::filesystem::weakly_canonical(path);
|
|
} |