Skip to content

Commit 407467f

Browse files
committed
Fix getProgramPath on macOS
1 parent 6be64b9 commit 407467f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Utilities/FileSystem.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
#include <unistd.h>
1414
#include <dirent.h>
1515
#endif
16+
#ifdef __APPLE__
17+
#include <mach-o/dyld.h>
18+
#endif
1619

1720
#ifndef S_ISDIR
1821
#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
@@ -217,6 +220,9 @@ namespace Utilities
217220
char buffer[1000];
218221
#ifdef WIN32
219222
GetModuleFileName(NULL, buffer, 1000);
223+
#elif defined(__APPLE__)
224+
uint32_t bufferSize = sizeof(buffer);
225+
_NSGetExecutablePath(buffer, &bufferSize);
220226
#else
221227
char szTmp[32];
222228
sprintf(szTmp, "/proc/%d/exe", getpid());

0 commit comments

Comments
 (0)