Use _NSGetExecutablePath on darwin

Closes #26.
This commit is contained in:
Joshua Peek 2011-04-28 01:15:06 +02:00 committed by Bert Belder
parent 40bb272a0c
commit 9b92e13721

View File

@ -39,12 +39,21 @@
static char executable_path[PATHMAX] = { '\0' };
#ifdef __APPLE__
#include <mach-o/dyld.h> /* _NSGetExecutablePath */
static void get_executable_path() {
uint32_t bufsize = sizeof(executable_path);
_NSGetExecutablePath(executable_path, &bufsize);
}
#else
/* Linux-only */
static void get_executable_path() {
if (!executable_path[0]) {
readlink("/proc/self/exe", executable_path, PATHMAX - 1);
}
}
#endif
/* Do platform-specific initialization. */