mirror of
https://github.com/hyprwm/hyprcursor.git
synced 2024-12-22 18:29:48 +01:00
lib: improve access checks on themes
This commit is contained in:
parent
1a1fcfb58d
commit
d3876f3477
1 changed files with 33 additions and 8 deletions
|
@ -49,14 +49,21 @@ static std::string getFirstTheme(PHYPRCURSORLOGFUNC logfn) {
|
|||
|
||||
for (auto& dir : userThemeDirs) {
|
||||
const auto FULLPATH = HOME + dir;
|
||||
if (!std::filesystem::exists(FULLPATH))
|
||||
if (!themeAccessible(FULLPATH) || !std::filesystem::exists(FULLPATH)) {
|
||||
Debug::log(HC_LOG_TRACE, logfn, "Skipping path {} because it's inaccessible.", FULLPATH);
|
||||
continue;
|
||||
}
|
||||
|
||||
// loop over dirs and see if any has a manifest.hl
|
||||
for (auto& themeDir : std::filesystem::directory_iterator(FULLPATH)) {
|
||||
if (!themeDir.is_directory())
|
||||
continue;
|
||||
|
||||
if (!themeAccessible(themeDir.path().string())) {
|
||||
Debug::log(HC_LOG_TRACE, logfn, "Skipping theme {} because it's inaccessible.", themeDir.path().string());
|
||||
continue;
|
||||
}
|
||||
|
||||
const auto MANIFESTPATH = themeDir.path().string() + "/manifest.hl";
|
||||
|
||||
if (std::filesystem::exists(MANIFESTPATH)) {
|
||||
|
@ -68,17 +75,24 @@ static std::string getFirstTheme(PHYPRCURSORLOGFUNC logfn) {
|
|||
|
||||
for (auto& dir : systemThemeDirs) {
|
||||
const auto FULLPATH = dir;
|
||||
if (!std::filesystem::exists(FULLPATH))
|
||||
if (!themeAccessible(FULLPATH) || !std::filesystem::exists(FULLPATH)) {
|
||||
Debug::log(HC_LOG_TRACE, logfn, "Skipping path {} because it's inaccessible.", FULLPATH);
|
||||
continue;
|
||||
}
|
||||
|
||||
// loop over dirs and see if any has a manifest.hl
|
||||
for (auto& themeDir : std::filesystem::directory_iterator(FULLPATH)) {
|
||||
if (!themeDir.is_directory())
|
||||
continue;
|
||||
|
||||
if (!themeAccessible(themeDir.path().string())) {
|
||||
Debug::log(HC_LOG_TRACE, logfn, "Skipping theme {} because it's inaccessible.", themeDir.path().string());
|
||||
continue;
|
||||
}
|
||||
|
||||
const auto MANIFESTPATH = themeDir.path().string() + "/manifest.hl";
|
||||
|
||||
if (std::filesystem::exists(MANIFESTPATH)) {
|
||||
if (!std::filesystem::exists(MANIFESTPATH)) {
|
||||
Debug::log(HC_LOG_INFO, logfn, "getFirstTheme: found {}", themeDir.path().string());
|
||||
return themeDir.path().stem().string();
|
||||
}
|
||||
|
@ -97,14 +111,21 @@ static std::string getFullPathForThemeName(const std::string& name, PHYPRCURSORL
|
|||
|
||||
for (auto& dir : userThemeDirs) {
|
||||
const auto FULLPATH = HOME + dir;
|
||||
if (!std::filesystem::exists(FULLPATH))
|
||||
if (!themeAccessible(FULLPATH) || !std::filesystem::exists(FULLPATH)) {
|
||||
Debug::log(HC_LOG_TRACE, logfn, "Skipping path {} because it's inaccessible.", FULLPATH);
|
||||
continue;
|
||||
}
|
||||
|
||||
// loop over dirs and see if any has a manifest.hl
|
||||
for (auto& themeDir : std::filesystem::directory_iterator(FULLPATH)) {
|
||||
if (!themeDir.is_directory())
|
||||
continue;
|
||||
|
||||
if (!themeAccessible(themeDir.path().string())) {
|
||||
Debug::log(HC_LOG_TRACE, logfn, "Skipping theme {} because it's inaccessible.", themeDir.path().string());
|
||||
continue;
|
||||
}
|
||||
|
||||
const auto MANIFESTPATH = themeDir.path().string() + "/manifest.hl";
|
||||
|
||||
if (name.empty()) {
|
||||
|
@ -138,16 +159,20 @@ static std::string getFullPathForThemeName(const std::string& name, PHYPRCURSORL
|
|||
|
||||
for (auto& dir : systemThemeDirs) {
|
||||
const auto FULLPATH = dir;
|
||||
if (!std::filesystem::exists(FULLPATH))
|
||||
if (!themeAccessible(FULLPATH) || !std::filesystem::exists(FULLPATH)) {
|
||||
Debug::log(HC_LOG_TRACE, logfn, "Skipping path {} because it's inaccessible.", FULLPATH);
|
||||
continue;
|
||||
}
|
||||
|
||||
// loop over dirs and see if any has a manifest.hl
|
||||
for (auto& themeDir : std::filesystem::directory_iterator(FULLPATH)) {
|
||||
if (!themeDir.is_directory())
|
||||
continue;
|
||||
|
||||
if (!themeAccessible(themeDir.path().string()))
|
||||
if (!themeAccessible(themeDir.path().string())) {
|
||||
Debug::log(HC_LOG_TRACE, logfn, "Skipping theme {} because it's inaccessible.", themeDir.path().string());
|
||||
continue;
|
||||
}
|
||||
|
||||
const auto MANIFESTPATH = themeDir.path().string() + "/manifest.hl";
|
||||
|
||||
|
|
Loading…
Reference in a new issue