added function to get the full path to the application bundle on os x
authorStefan Gartner <stefang@aon.at>
Mon, 12 May 2003 14:59:08 +0000 (14:59 +0000)
committerStefan Gartner <stefang@aon.at>
Mon, 12 May 2003 14:59:08 +0000 (14:59 +0000)
source/blender/blenlib/BLI_blenlib.h
source/blender/blenlib/intern/util.c

index b5dbf002b8465e721c9cd9b4591bb90d037801a6..8d07c7668f87f0eac7a6b17ab5dceefdd51d20ed 100644 (file)
@@ -203,6 +203,15 @@ void BLI_free_file_lines(struct LinkNode *lines);
         */
 void BLI_where_am_i(char *fullname, char *name);
 
+       /**
+        * determines the full path to the application bundle on OS X
+        *
+        * @return path to application bundle
+        */
+#ifdef __APPLE__
+char* BLI_getbundle(void);
+#endif
+               
 /* BLI_storage.h */
 int    BLI_filesize(int file);
 double BLI_diskfree(char *dir);
index eb2109ba807f3185bd5bafe0e85c3291e22caca0..80813b1119ee6d7a043c7864e47cc36847990f26 100644 (file)
 #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
+