/proc/self/exe does not exist on MacOS.

Fixes https://github.com/audetto/AppleWin/issues/54

Signed-off-by: Andrea Odetti <mariofutire@gmail.com>
This commit is contained in:
Andrea Odetti 2022-01-03 16:32:29 +00:00
parent fa60480875
commit 1f1a0f0c3f

View file

@ -10,6 +10,10 @@
#include <unistd.h>
#include <libgen.h>
#ifdef __APPLE__
#include "mach-o/dyld.h"
#endif
#include "Log.h"
#include "Core.h"
#include "config.h"
@ -36,7 +40,14 @@ namespace
std::vector<std::string> 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);