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>
11 static const char nsgep_too_long[] = "NSGetExecutablePath() wants to return a path too large";
13 /* --- XS ------------------------------------------------------------------ */
15 MODULE = Mac::NSGetExecutablePath PACKAGE = Mac::NSGetExecutablePath
24 uint32_t size = sizeof buf;
28 _NSGetExecutablePath(buf, &size);
29 if (size >= MAXPATHLEN * MAXPATHLEN)
30 croak(nsgep_too_long);
32 sv_upgrade(dst, SVt_PV);
33 buffer = SvGROW(dst, size);
34 if (_NSGetExecutablePath(buffer, &size))
35 croak(nsgep_too_long);
37 SvCUR_set(dst, size - 1);