shithub: femtolisp

Download patch

ref: bf5e0d221034acd1b390c8a563d25899765225d7
parent: 41504aa58b24afadb1d50a39de173e6fa308c248
parent: 49ec8cf379d107353b0036ad16d24205fbeb5d52
author: Jeff Bezanson <jeff.bezanson@gmail.com>
date: Sat Sep 17 10:43:59 EDT 2016

Merge pull request #18 from schani/master

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