Implement Linux executable directory lookup

This commit is contained in:
patchzyy
2026-09-07 23:14:51 +02:00
parent 9066cb3560
commit e05e15bce5
+7
View File
@@ -46,6 +46,13 @@ std::optional<std::filesystem::path> ExecutableDirectory() noexcept {
std::error_code ec;
const auto resolved = std::filesystem::weakly_canonical(path, ec);
return (ec ? std::filesystem::path(path) : resolved).parent_path();
#elif defined(__linux__)
std::error_code ec;
const auto executable = std::filesystem::read_symlink("/proc/self/exe", ec);
if (ec) {
return std::nullopt;
}
return executable.parent_path();
#else
return std::nullopt;
#endif