From 73721de9ae5a2a120d7bc4e74577ab431e940f97 Mon Sep 17 00:00:00 2001 From: vaxerski Date: Tue, 2 Apr 2024 15:28:31 +0100 Subject: [PATCH] lib: fixup path accessibility lookups --- libhyprcursor/hyprcursor.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/libhyprcursor/hyprcursor.cpp b/libhyprcursor/hyprcursor.cpp index 2877b75..304ab9f 100644 --- a/libhyprcursor/hyprcursor.cpp +++ b/libhyprcursor/hyprcursor.cpp @@ -28,9 +28,9 @@ static std::string themeNameFromEnv(PHYPRCURSORLOGFUNC logfn) { return std::string{ENV}; } -static bool themeAccessible(const std::string& path) { +static bool pathAccessible(const std::string& path) { try { - if (!std::filesystem::exists(path + "/manifest.hl")) + if (!std::filesystem::exists(path)) return false; } catch (std::exception& e) { return false; } @@ -38,6 +38,10 @@ static bool themeAccessible(const std::string& path) { return true; } +static bool themeAccessible(const std::string& path) { + return pathAccessible(path + "/manifest.hl"); +} + static std::string getFirstTheme(PHYPRCURSORLOGFUNC logfn) { // try user directories first @@ -49,7 +53,7 @@ static std::string getFirstTheme(PHYPRCURSORLOGFUNC logfn) { for (auto& dir : userThemeDirs) { 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); continue; } @@ -75,7 +79,7 @@ static std::string getFirstTheme(PHYPRCURSORLOGFUNC logfn) { for (auto& dir : systemThemeDirs) { 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); continue; } @@ -111,7 +115,7 @@ static std::string getFullPathForThemeName(const std::string& name, PHYPRCURSORL for (auto& dir : userThemeDirs) { 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); continue; } @@ -159,7 +163,7 @@ static std::string getFullPathForThemeName(const std::string& name, PHYPRCURSORL for (auto& dir : systemThemeDirs) { 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); continue; }