From 3c10ecc0be7c71a9ca16869e8c89a160e1966bc5 Mon Sep 17 00:00:00 2001 From: Mark Probst Date: Wed, 6 May 2015 15:36:41 -0700 Subject: [PATCH] get_exename() for OSX >= 10.9 --- llt/dirpath.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/llt/dirpath.c b/llt/dirpath.c index df56dc8..962af38 100644 --- a/llt/dirpath.c +++ b/llt/dirpath.c @@ -119,17 +119,12 @@ char *get_exename(char *buf, size_t size) return buf; } #elif defined(MACOSX) -#include +#include 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