/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:
parent
fa60480875
commit
1f1a0f0c3f
1 changed files with 11 additions and 0 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue