support exe-relative reference to the main exe
svn: r2793
This commit is contained in:
parent
8b1d609a63
commit
1eee81ca66
|
@ -483,6 +483,34 @@ char *ConvertCFStringRef(CFStringRef str)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *ExeRelativeToAbsolute(char *p)
|
||||||
|
{
|
||||||
|
CFBundleRef appBundle;
|
||||||
|
CFURLRef url;
|
||||||
|
CFStringRef str;
|
||||||
|
char *s, *a;
|
||||||
|
long len, len2, len3;
|
||||||
|
|
||||||
|
appBundle = CFBundleGetMainBundle();
|
||||||
|
url = CFBundleCopyExecutableURL(appBundle);
|
||||||
|
str = CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle);
|
||||||
|
|
||||||
|
s = ConvertCFStringRef(str);
|
||||||
|
|
||||||
|
len = strlen(s);
|
||||||
|
while (len && (s[len - 1] != '/')) {
|
||||||
|
--len;
|
||||||
|
}
|
||||||
|
|
||||||
|
len2 = strlen(p);
|
||||||
|
|
||||||
|
a = (char *)malloc(len + len2 + 1);
|
||||||
|
memcpy(a, s, len);
|
||||||
|
memcpy(a + len, p, len2 + 1);
|
||||||
|
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
void GetStarterInfo()
|
void GetStarterInfo()
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
@ -502,6 +530,10 @@ void GetStarterInfo()
|
||||||
execName = (CFStringRef)CFDictionaryGetValue((CFDictionaryRef)propertyList,
|
execName = (CFStringRef)CFDictionaryGetValue((CFDictionaryRef)propertyList,
|
||||||
(CFSTR("executable name")));
|
(CFSTR("executable name")));
|
||||||
tmps = ConvertCFStringRef(execName);
|
tmps = ConvertCFStringRef(execName);
|
||||||
|
if (tmps[0] != '/') {
|
||||||
|
/* Path is relative to this executable */
|
||||||
|
tmps = ExeRelativeToAbsolute(tmps);
|
||||||
|
}
|
||||||
orig_argv0 = scheme_mac_argv[0];
|
orig_argv0 = scheme_mac_argv[0];
|
||||||
scheme_mac_argv[0] = tmps;
|
scheme_mac_argv[0] = tmps;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user