summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--txr.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/txr.c b/txr.c
index 5f2ea883..428a0ff0 100644
--- a/txr.c
+++ b/txr.c
@@ -40,6 +40,9 @@
#include <windows.h>
#undef TEXT
#endif
+#if __APPLE__
+#include <mach-o/dyld.h>
+#endif
#include "lib.h"
#include "stream.h"
#include "gc.h"
@@ -230,6 +233,16 @@ static val get_self_path(void)
return string(self);
}
+#elif __APPLE__
+static val get_self_path(void)
+{
+ char self[PATH_MAX] = { 0 };
+ uint32_t size = sizeof self;
+
+ if (_NSGetExecutablePath(self, &size) != 0)
+ return nil;
+ return string_utf8(self);
+}
#else
static val get_self_path(void)
{