added function to get the full path to the application bundle on os x

This commit is contained in:
2003-05-12 14:59:08 +00:00
parent 331eb81e09
commit 23e8e19f5c
2 changed files with 33 additions and 0 deletions

View File

@@ -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