Return path including executable instead of without

The previous implementation returned the path the executable was in instead
of returning the path including the executable (i.e. it returned ...bin
instead of ...bin/executable). This is not what the original methods did
and caused the process forking of adb to fail.

This patch corrects the implementation.

Change-Id: Ib58497cab35706041f170c1bc97c31fd5d965f90
This commit is contained in:
Al Sutton 2014-11-20 13:33:57 +00:00
parent 46ee85fcc3
commit 26b53bb75e
2 changed files with 10 additions and 10 deletions

View File

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

View File

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