2015-01-29 05:02:18 +00:00
|
|
|
#include "mac_resources.h"
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <CoreFoundation/CoreFoundation.h>
|
|
|
|
|
|
|
|
void OSX_GetResourcesPath(char * buffer)
|
|
|
|
{
|
|
|
|
CFBundleRef mainBundle;
|
|
|
|
mainBundle = CFBundleGetMainBundle();
|
|
|
|
if (mainBundle)
|
|
|
|
{
|
2016-05-18 03:56:49 +00:00
|
|
|
const int BUF_SIZE = 256; // because we somehow always know that
|
|
|
|
|
2015-01-29 05:02:18 +00:00
|
|
|
CFURLRef appUrlRef = CFBundleCopyBundleURL(mainBundle);
|
2016-05-19 03:13:53 +00:00
|
|
|
CFStringRef macPath;
|
|
|
|
if (appUrlRef != NULL)
|
|
|
|
macPath = CFURLCopyFileSystemPath(appUrlRef, kCFURLPOSIXPathStyle);
|
|
|
|
else
|
|
|
|
macPath = NULL;
|
2016-05-18 03:56:49 +00:00
|
|
|
|
2016-05-19 03:13:53 +00:00
|
|
|
const char* rawPath;
|
|
|
|
|
|
|
|
if (macPath != NULL)
|
|
|
|
rawPath = CFStringGetCStringPtr(macPath, kCFStringEncodingASCII);
|
|
|
|
else
|
|
|
|
rawPath = NULL;
|
|
|
|
|
|
|
|
if (rawPath != NULL && (CFStringGetLength(macPath) + strlen("/Contents/Resources") < BUF_SIZE))
|
2016-05-18 03:56:49 +00:00
|
|
|
{
|
|
|
|
strcpy(buffer, rawPath);
|
|
|
|
strcat(buffer, "/Contents/Resources");
|
|
|
|
}
|
|
|
|
|
2015-01-29 05:02:18 +00:00
|
|
|
CFRelease(macPath);
|
|
|
|
CFRelease(appUrlRef);
|
|
|
|
}
|
2016-05-18 03:56:49 +00:00
|
|
|
}
|