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 dst = newSV_type(SVt_PV);
36 (void) SvUPGRADE(dst, SVt_PV);
38 buffer = SvGROW(dst, size);
39 if (_NSGetExecutablePath(buffer, &size))
40 croak(nsgep_too_long);
41 SvCUR_set(dst, size - 1);