added function to get the full path to the application bundle on os x
This commit is contained in:
@@ -69,6 +69,12 @@
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
#endif
|
||||
|
||||
/* local */
|
||||
|
||||
static int add_win32_extension(char *name);
|
||||
@@ -834,3 +840,21 @@ void BLI_where_am_i(char *fullname, char *name)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* returns absolute path to the app bundle
|
||||
* only useful on OS X
|
||||
*/
|
||||
#ifdef __APPLE__
|
||||
char* BLI_getbundle(void) {
|
||||
CFURLRef bundleURL;
|
||||
CFStringRef pathStr;
|
||||
char path[MAXPATHLEN];
|
||||
CFBundleRef mainBundle = CFBundleGetMainBundle();
|
||||
|
||||
bundleURL = CFBundleCopyBundleURL(mainBundle);
|
||||
pathStr = CFURLCopyFileSystemPath(bundleURL, kCFURLPOSIXPathStyle);
|
||||
CFStringGetCString(pathStr, path, MAXPATHLEN, kCFStringEncodingASCII);
|
||||
return path;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
Reference in New Issue
Block a user