mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-17 10:11:02 +00:00
Simplify OS X bundle resource discovery, fix a sigsegv
This commit is contained in:
parent
a12733f480
commit
928c6acf4b
1 changed files with 13 additions and 15 deletions
|
@ -9,23 +9,21 @@ void OSX_GetResourcesPath(char * buffer)
|
|||
mainBundle = CFBundleGetMainBundle();
|
||||
if (mainBundle)
|
||||
{
|
||||
const int BUF_SIZE = 256; // because we somehow always know that
|
||||
|
||||
CFURLRef appUrlRef = CFBundleCopyBundleURL(mainBundle);
|
||||
CFStringRef macPath = CFURLCopyFileSystemPath(appUrlRef, kCFURLPOSIXPathStyle);
|
||||
CFStringRef resources = CFStringCreateWithCString(kCFAllocatorMalloc, "/Contents/Resources", kCFStringEncodingASCII);
|
||||
const void* rawarray[2] = {macPath, resources};
|
||||
CFArrayRef array = CFArrayCreate(kCFAllocatorMalloc, rawarray, 2, NULL);
|
||||
CFStringRef separator = CFStringCreateWithCString(kCFAllocatorMalloc, "", kCFStringEncodingASCII);
|
||||
CFStringRef fullPath = CFStringCreateByCombiningStrings(kCFAllocatorMalloc, array, separator);
|
||||
const char * path = CFStringGetCStringPtr(fullPath, kCFStringEncodingASCII);
|
||||
strcpy(buffer, path);
|
||||
CFRelease(fullPath);
|
||||
path = NULL;
|
||||
CFRelease(array);
|
||||
CFRelease(resources);
|
||||
|
||||
const char* rawPath = CFStringGetCStringPtr(macPath, kCFStringEncodingASCII);
|
||||
|
||||
if (CFStringGetLength(macPath) + strlen("/Contents/Resources") < BUF_SIZE)
|
||||
{
|
||||
strcpy(buffer, rawPath);
|
||||
strcat(buffer, "/Contents/Resources");
|
||||
}
|
||||
|
||||
CFRelease(macPath);
|
||||
CFRelease(appUrlRef);
|
||||
//CFRelease(mainBundle);
|
||||
CFRelease(separator);
|
||||
}
|
||||
|
||||
}
|
||||
CFRelease(mainBundle);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue