File/installation paths: osx (cocoa & carbon) update in ghost
[blender.git] / intern / ghost / intern / GHOST_SystemCocoa.mm
index b093510c700415ae1af765f3ab2594eaa5857ae1..f65d4e93d592835c9dd2f205390bd2a9f432f02c 100644 (file)
@@ -1783,27 +1783,20 @@ void GHOST_SystemCocoa::putClipboard(GHOST_TInt8 *buffer, bool selection) const
 
 #pragma mark Base directories retrieval
 
-// TODO: this should only return base path, remove the appending of Blender or .blender
 const GHOST_TUns8* GHOST_SystemCocoa::getSystemDir() const
 {
        static GHOST_TUns8 tempPath[512] = "";
        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-       NSFileManager *fileManager;
        NSString *basePath;
        NSArray *paths;
        
        paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSLocalDomainMask, YES);
        
        if ([paths count] > 0)
-               basePath = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"Blender"];
-       else { //Fall back to standard unix path in case of issue
-               basePath = @"/usr/share/blender";
-       }
-       
-       /* Ensure path exists, creates it if needed */
-       fileManager = [NSFileManager defaultManager];
-       if (![fileManager fileExistsAtPath:basePath isDirectory:NULL]) {
-               [fileManager createDirectoryAtPath:basePath attributes:nil];
+               basePath = [paths objectAtIndex:0];
+       else { 
+               [pool drain];
+               return NULL;
        }
        
        strcpy((char*)tempPath, [basePath cStringUsingEncoding:NSASCIIStringEncoding]);
@@ -1812,56 +1805,39 @@ const GHOST_TUns8* GHOST_SystemCocoa::getSystemDir() const
        return tempPath;
 }
 
-// TODO: this should only return base path, remove the appending of Blenbder or .blender
 const GHOST_TUns8* GHOST_SystemCocoa::getUserDir() const
 {
        static GHOST_TUns8 tempPath[512] = "";
        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-       NSFileManager *fileManager;
        NSString *basePath;
        NSArray *paths;
 
        paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
 
        if ([paths count] > 0)
-               basePath = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"Blender"];
-       else { //Fall back to HOME in case of issue
-               basePath = [NSHomeDirectory() stringByAppendingPathComponent:@".blender"];
-       }
-       
-       /* Ensure path exists, creates it if needed */
-       fileManager = [NSFileManager defaultManager];
-       if (![fileManager fileExistsAtPath:basePath isDirectory:NULL]) {
-               [fileManager createDirectoryAtPath:basePath attributes:nil];
+               basePath = [paths objectAtIndex:0];
+       else { 
+               [pool drain];
+               return NULL;
        }
-       
+
        strcpy((char*)tempPath, [basePath cStringUsingEncoding:NSASCIIStringEncoding]);
        
        [pool drain];
        return tempPath;
 }
 
-// TODO: this is same as getUserDir for now
 const GHOST_TUns8* GHOST_SystemCocoa::getBinaryDir() const
 {
        static GHOST_TUns8 tempPath[512] = "";
        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-       NSFileManager *fileManager;
        NSString *basePath;
-       NSArray *paths;
-
-       paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
-
-       if ([paths count] > 0)
-               basePath = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"Blender"];
-       else { //Fall back to HOME in case of issue
-               basePath = [NSHomeDirectory() stringByAppendingPathComponent:@".blender"];
-       }
        
-       /* Ensure path exists, creates it if needed */
-       fileManager = [NSFileManager defaultManager];
-       if (![fileManager fileExistsAtPath:basePath isDirectory:NULL]) {
-               [fileManager createDirectoryAtPath:basePath attributes:nil];
+       basePath = [[NSBundle mainBundle] bundlePath];
+       
+       if (basePath == nil) {
+               [pool drain];
+               return NULL;
        }
        
        strcpy((char*)tempPath, [basePath cStringUsingEncoding:NSASCIIStringEncoding]);