mirror of
https://github.com/hyprwm/hyprcursor.git
synced 2024-11-16 18:25:58 +01:00
lib: fixup path accessibility lookups
This commit is contained in:
parent
d3876f3477
commit
73721de9ae
1 changed files with 10 additions and 6 deletions
|
@ -28,9 +28,9 @@ static std::string themeNameFromEnv(PHYPRCURSORLOGFUNC logfn) {
|
||||||
return std::string{ENV};
|
return std::string{ENV};
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool themeAccessible(const std::string& path) {
|
static bool pathAccessible(const std::string& path) {
|
||||||
try {
|
try {
|
||||||
if (!std::filesystem::exists(path + "/manifest.hl"))
|
if (!std::filesystem::exists(path))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
} catch (std::exception& e) { return false; }
|
} catch (std::exception& e) { return false; }
|
||||||
|
@ -38,6 +38,10 @@ static bool themeAccessible(const std::string& path) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool themeAccessible(const std::string& path) {
|
||||||
|
return pathAccessible(path + "/manifest.hl");
|
||||||
|
}
|
||||||
|
|
||||||
static std::string getFirstTheme(PHYPRCURSORLOGFUNC logfn) {
|
static std::string getFirstTheme(PHYPRCURSORLOGFUNC logfn) {
|
||||||
// try user directories first
|
// try user directories first
|
||||||
|
|
||||||
|
@ -49,7 +53,7 @@ static std::string getFirstTheme(PHYPRCURSORLOGFUNC logfn) {
|
||||||
|
|
||||||
for (auto& dir : userThemeDirs) {
|
for (auto& dir : userThemeDirs) {
|
||||||
const auto FULLPATH = HOME + dir;
|
const auto FULLPATH = HOME + dir;
|
||||||
if (!themeAccessible(FULLPATH) || !std::filesystem::exists(FULLPATH)) {
|
if (!pathAccessible(FULLPATH)) {
|
||||||
Debug::log(HC_LOG_TRACE, logfn, "Skipping path {} because it's inaccessible.", FULLPATH);
|
Debug::log(HC_LOG_TRACE, logfn, "Skipping path {} because it's inaccessible.", FULLPATH);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -75,7 +79,7 @@ static std::string getFirstTheme(PHYPRCURSORLOGFUNC logfn) {
|
||||||
|
|
||||||
for (auto& dir : systemThemeDirs) {
|
for (auto& dir : systemThemeDirs) {
|
||||||
const auto FULLPATH = dir;
|
const auto FULLPATH = dir;
|
||||||
if (!themeAccessible(FULLPATH) || !std::filesystem::exists(FULLPATH)) {
|
if (!pathAccessible(FULLPATH)) {
|
||||||
Debug::log(HC_LOG_TRACE, logfn, "Skipping path {} because it's inaccessible.", FULLPATH);
|
Debug::log(HC_LOG_TRACE, logfn, "Skipping path {} because it's inaccessible.", FULLPATH);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -111,7 +115,7 @@ static std::string getFullPathForThemeName(const std::string& name, PHYPRCURSORL
|
||||||
|
|
||||||
for (auto& dir : userThemeDirs) {
|
for (auto& dir : userThemeDirs) {
|
||||||
const auto FULLPATH = HOME + dir;
|
const auto FULLPATH = HOME + dir;
|
||||||
if (!themeAccessible(FULLPATH) || !std::filesystem::exists(FULLPATH)) {
|
if (!pathAccessible(FULLPATH)) {
|
||||||
Debug::log(HC_LOG_TRACE, logfn, "Skipping path {} because it's inaccessible.", FULLPATH);
|
Debug::log(HC_LOG_TRACE, logfn, "Skipping path {} because it's inaccessible.", FULLPATH);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -159,7 +163,7 @@ static std::string getFullPathForThemeName(const std::string& name, PHYPRCURSORL
|
||||||
|
|
||||||
for (auto& dir : systemThemeDirs) {
|
for (auto& dir : systemThemeDirs) {
|
||||||
const auto FULLPATH = dir;
|
const auto FULLPATH = dir;
|
||||||
if (!themeAccessible(FULLPATH) || !std::filesystem::exists(FULLPATH)) {
|
if (!pathAccessible(FULLPATH)) {
|
||||||
Debug::log(HC_LOG_TRACE, logfn, "Skipping path {} because it's inaccessible.", FULLPATH);
|
Debug::log(HC_LOG_TRACE, logfn, "Skipping path {} because it's inaccessible.", FULLPATH);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue