ref: 49ec8cf379d107353b0036ad16d24205fbeb5d52
parent: 2923137ef047b401d560766537782f60e67f9a0c
author: Mark Probst <mark.probst@gmail.com>
date: Wed May 6 11:36:41 EDT 2015
get_exename() for OSX >= 10.9
--- a/llt/dirpath.c
+++ b/llt/dirpath.c
@@ -119,17 +119,12 @@
return buf;
}
#elif defined(MACOSX)
-#include <ApplicationServices/ApplicationServices.h>
+#include <mach-o/dyld.h>
char *get_exename(char *buf, size_t size)
{
- ProcessSerialNumber PSN;
- FSRef ref;
-
- if (GetCurrentProcess(&PSN) < 0 ||
- GetProcessBundleLocation(&PSN, &ref) < 0 ||
- FSRefMakePath(&ref, buf, size) < 0)
- return NULL;
-
+ uint32_t bufsize = (uint32_t)size;
+ if (_NSGetExecutablePath(buf, &bufsize))
+ return NULL;
return buf;
}
#endif