From e89634df44fd47c372f3de08cff9d5a8c7f64575 Mon Sep 17 00:00:00 2001 From: "Mr. Myxa" Date: Sat, 17 Oct 2026 11:49:50 +0200 Subject: [PATCH 1/3] fix lookup logic and small refactor (remove redundant std::filesystem calls) --- src/helpers/fs/FsUtils.cpp | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/src/helpers/fs/FsUtils.cpp b/src/helpers/fs/FsUtils.cpp index b687ca7fc94..5b7a25c32b8 100644 --- a/src/helpers/fs/FsUtils.cpp +++ b/src/helpers/fs/FsUtils.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -84,28 +85,31 @@ bool NFsUtils::writeToFile(const std::string& path, const std::string& content) } bool NFsUtils::executableExistsInPath(const std::string& exe) { - if (!getenv("PATH")) + const char* const path = std::getenv("PATH"); + if (path == nullptr) return false; - static CVarList paths(getenv("PATH"), 0, ':', true); + static CVarList paths(path, 0, ':', true); - for (auto& p : paths) { - std::string path = p + std::string{"/"} + exe; - std::error_code ec; - if (!std::filesystem::exists(path, ec) || ec) - continue; + std::string fullPath; + fullPath.reserve(256); - if (!std::filesystem::is_regular_file(path, ec) || ec) - continue; + return std::ranges::any_of(paths, [&](const std::string& dir) -> bool { + fullPath = dir; - auto stat = std::filesystem::status(path, ec); - if (ec) - continue; + if (!fullPath.ends_with('/')) { + fullPath.push_back('/'); + } - auto perms = stat.permissions(); + fullPath += exe; - return std::filesystem::perms::none != (perms & std::filesystem::perms::others_exec); - } + std::error_code ec; + auto status = std::filesystem::status(fullPath, ec); + + if (ec || !std::filesystem::is_regular_file(status)) { + return false; + } - return false; + return (status.permissions() & std::filesystem::perms::others_exec) != std::filesystem::perms::none; + }); } From 71c212b3d841b39437a2de8b28a70b2a655f139e Mon Sep 17 00:00:00 2001 From: "Mr. Myxa" Date: Sun, 18 Oct 2026 10:20:56 +0200 Subject: [PATCH 2/3] replace CVarList with CVarList2 --- src/helpers/fs/FsUtils.cpp | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/helpers/fs/FsUtils.cpp b/src/helpers/fs/FsUtils.cpp index 5b7a25c32b8..20b3948b72f 100644 --- a/src/helpers/fs/FsUtils.cpp +++ b/src/helpers/fs/FsUtils.cpp @@ -7,7 +7,7 @@ #include #include -#include +#include using namespace Hyprutils::String; std::optional NFsUtils::getDataHome() { @@ -89,19 +89,12 @@ bool NFsUtils::executableExistsInPath(const std::string& exe) { if (path == nullptr) return false; - static CVarList paths(path, 0, ':', true); + static CVarList2 paths(std::string{path}, 0, ':', true); - std::string fullPath; - fullPath.reserve(256); - - return std::ranges::any_of(paths, [&](const std::string& dir) -> bool { + std::filesystem::path fullPath; + return std::ranges::any_of(paths, [&](std::string_view dir) -> bool { fullPath = dir; - - if (!fullPath.ends_with('/')) { - fullPath.push_back('/'); - } - - fullPath += exe; + fullPath /= exe; std::error_code ec; auto status = std::filesystem::status(fullPath, ec); From 9e7c719b809886a5aeba2befbc59ee6fe41b31d6 Mon Sep 17 00:00:00 2001 From: "Mr. Myxa" Date: Sun, 18 Oct 2026 10:22:39 +0200 Subject: [PATCH 3/3] fix if --- src/helpers/fs/FsUtils.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/helpers/fs/FsUtils.cpp b/src/helpers/fs/FsUtils.cpp index 20b3948b72f..d32946f92ae 100644 --- a/src/helpers/fs/FsUtils.cpp +++ b/src/helpers/fs/FsUtils.cpp @@ -99,9 +99,8 @@ bool NFsUtils::executableExistsInPath(const std::string& exe) { std::error_code ec; auto status = std::filesystem::status(fullPath, ec); - if (ec || !std::filesystem::is_regular_file(status)) { + if (ec || !std::filesystem::is_regular_file(status)) return false; - } return (status.permissions() & std::filesystem::perms::others_exec) != std::filesystem::perms::none; });