From 1f1a0f0c3fe0f0cde5ad965bef0ab4eb5215ac50 Mon Sep 17 00:00:00 2001 From: Andrea Odetti Date: Mon, 3 Jan 2022 16:32:29 +0000 Subject: [PATCH] /proc/self/exe does not exist on MacOS. Fixes https://github.com/audetto/AppleWin/issues/54 Signed-off-by: Andrea Odetti --- source/frontends/common2/commonframe.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/source/frontends/common2/commonframe.cpp b/source/frontends/common2/commonframe.cpp index 5965498c2..bf6774ebb 100644 --- a/source/frontends/common2/commonframe.cpp +++ b/source/frontends/common2/commonframe.cpp @@ -10,6 +10,10 @@ #include #include +#ifdef __APPLE__ +#include "mach-o/dyld.h" +#endif + #include "Log.h" #include "Core.h" #include "config.h" @@ -36,7 +40,14 @@ namespace std::vector paths; char self[1024] = {0}; + +#ifdef __APPLE__ + uint32_t size = sizeof(self); + const int ch = _NSGetExecutablePath(self, &size); +#else const int ch = readlink("/proc/self/exe", self, sizeof(self)); +#endif + if (ch != -1) { const char * path = dirname(self);