Merge "Return path including executable instead of without"

This commit is contained in:
Elliott Hughes 2014-11-20 18:35:12 +00:00 committed by Gerrit Code Review
commit aa3e17e1b6
2 changed files with 10 additions and 10 deletions

View file

@ -20,11 +20,11 @@
void get_my_path(char *s, size_t maxLen) void get_my_path(char *s, size_t maxLen)
{ {
CFBundleRef mainBundle = CFBundleGetMainBundle(); CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef bundleURL = CFBundleCopyBundleURL(mainBundle); CFURLRef executableURL = CFBundleCopyExecutableURL(mainBundle);
CFStringRef bundlePathString = CFURLCopyFileSystemPath(bundleURL, kCFURLPOSIXPathStyle); CFStringRef executablePathString = CFURLCopyFileSystemPath(executableURL, kCFURLPOSIXPathStyle);
CFRelease(bundleURL); CFRelease(executableURL);
CFStringGetCString(bundlePathString, s, maxLen, kCFStringEncodingASCII); CFStringGetCString(executablePathString, s, maxLen, kCFStringEncodingASCII);
CFRelease(bundlePathString); CFRelease(executablePathString);
} }

View file

@ -32,12 +32,12 @@
void get_my_path(char s[PATH_MAX]) void get_my_path(char s[PATH_MAX])
{ {
CFBundleRef mainBundle = CFBundleGetMainBundle(); CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef bundleURL = CFBundleCopyBundleURL(mainBundle); CFURLRef executableURL = CFBundleCopyExecutableURL(mainBundle);
CFStringRef bundlePathString = CFURLCopyFileSystemPath(bundleURL, kCFURLPOSIXPathStyle); CFStringRef executablePathString = CFURLCopyFileSystemPath(executableURL, kCFURLPOSIXPathStyle);
CFRelease(bundleURL); CFRelease(executableURL);
CFStringGetCString(bundlePathString, s, PATH_MAX - 1, kCFStringEncodingASCII); CFStringGetCString(executablePathString, s, PATH_MAX-1, kCFStringEncodingASCII);
CFRelease(bundlePathString); CFRelease(executablePathString);
char *x; char *x;
x = strrchr(s, '/'); x = strrchr(s, '/');