1 /* This file is part of the Mac::NSGetExecutablePath Perl module.
2 * See http://search.cpan.org/dist/Mac-NSGetExecutablePath/ */
4 #define PERL_NO_GET_CONTEXT
9 #include <mach-o/dyld.h>
12 static const char nsgep_too_long[] = "NSGetExecutablePath() wants to return a path too large";
14 /* --- XS ------------------------------------------------------------------ */
16 MODULE = Mac::NSGetExecutablePath PACKAGE = Mac::NSGetExecutablePath
25 uint32_t size = sizeof buf;
29 _NSGetExecutablePath(buf, &size);
30 if (size >= MAXPATHLEN * MAXPATHLEN)
31 croak(nsgep_too_long);
33 sv_upgrade(dst, SVt_PV);
34 buffer = SvGROW(dst, size);
35 if (_NSGetExecutablePath(buffer, &size))
36 croak(nsgep_too_long);
38 SvCUR_set(dst, size - 1);