am 20860a28: Merge "Fix building on modern versions of Xcode and OS X."

* commit '20860a28c5be013da111cb794c92dae02aa30089':
  Fix building on modern versions of Xcode and OS X.
This commit is contained in:
Elliott Hughes 2014-11-19 21:55:28 +00:00 committed by Android Git Automerger
commit 2097e9a149
2 changed files with 16 additions and 15 deletions

View File

@ -19,12 +19,12 @@
void get_my_path(char *s, size_t maxLen)
{
ProcessSerialNumber psn;
GetCurrentProcess(&psn);
CFDictionaryRef dict;
dict = ProcessInformationCopyDictionary(&psn, 0xffffffff);
CFStringRef value = (CFStringRef)CFDictionaryGetValue(dict,
CFSTR("CFBundleExecutable"));
CFStringGetCString(value, s, maxLen, kCFStringEncodingUTF8);
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef bundleURL = CFBundleCopyBundleURL(mainBundle);
CFStringRef bundlePathString = CFURLCopyFileSystemPath(bundleURL, kCFURLPOSIXPathStyle);
CFRelease(bundleURL);
CFStringGetCString(bundlePathString, s, maxLen, kCFStringEncodingASCII);
CFRelease(bundlePathString);
}

View File

@ -31,14 +31,15 @@
void get_my_path(char s[PATH_MAX])
{
char *x;
ProcessSerialNumber psn;
GetCurrentProcess(&psn);
CFDictionaryRef dict;
dict = ProcessInformationCopyDictionary(&psn, 0xffffffff);
CFStringRef value = (CFStringRef)CFDictionaryGetValue(dict,
CFSTR("CFBundleExecutable"));
CFStringGetCString(value, s, PATH_MAX - 1, kCFStringEncodingUTF8);
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef bundleURL = CFBundleCopyBundleURL(mainBundle);
CFStringRef bundlePathString = CFURLCopyFileSystemPath(bundleURL, kCFURLPOSIXPathStyle);
CFRelease(bundleURL);
CFStringGetCString(bundlePathString, s, PATH_MAX - 1, kCFStringEncodingASCII);
CFRelease(bundlePathString);
char *x;
x = strrchr(s, '/');
if(x) x[1] = 0;
}