From 810770564e12a4232e1b8efe8caef00d8cd07751 Mon Sep 17 00:00:00 2001 From: lisyarus Date: Tue, 30 Jun 2026 23:46:26 +0300 Subject: [PATCH] Implement util::executable_path() for macos --- libs/util/source/executable_path.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libs/util/source/executable_path.cpp b/libs/util/source/executable_path.cpp index ba8a9dc8..3095fe52 100644 --- a/libs/util/source/executable_path.cpp +++ b/libs/util/source/executable_path.cpp @@ -8,6 +8,10 @@ #include #endif +#ifdef __APPLE__ +#include +#endif + namespace psemek::util { @@ -29,6 +33,12 @@ namespace psemek::util return std::filesystem::path(result); #elif defined __linux__ return std::filesystem::canonical("/proc/self/exe"); +#elif defined __APPLE__ + uint32_t path_length = 0; + _NSGetExecutablePath(nullptr, &path_length); + std::string path(path_length, '\0'); + _NSGetExecutablePath(path.data(), &path_length); + return std::filesystem::path(std::move(path)); #else throw exception("executable_path() is not implemented for this platform"); #endif