|
Blender
V2.59
|
00001 00029 #import <Cocoa/Cocoa.h> 00030 00031 /*For the currently not ported to Cocoa keyboard layout functions (64bit & 10.6 compatible)*/ 00032 #include <Carbon/Carbon.h> 00033 00034 #include <sys/time.h> 00035 #include <sys/types.h> 00036 #include <sys/sysctl.h> 00037 00038 #include "GHOST_SystemPathsCocoa.h" 00039 00040 00041 #pragma mark initialization/finalization 00042 00043 00044 GHOST_SystemPathsCocoa::GHOST_SystemPathsCocoa() 00045 { 00046 } 00047 00048 GHOST_SystemPathsCocoa::~GHOST_SystemPathsCocoa() 00049 { 00050 } 00051 00052 00053 #pragma mark Base directories retrieval 00054 00055 const GHOST_TUns8* GHOST_SystemPathsCocoa::getSystemDir() const 00056 { 00057 static GHOST_TUns8 tempPath[512] = ""; 00058 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 00059 NSString *basePath; 00060 NSArray *paths; 00061 00062 paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSLocalDomainMask, YES); 00063 00064 if ([paths count] > 0) 00065 basePath = [paths objectAtIndex:0]; 00066 else { 00067 [pool drain]; 00068 return NULL; 00069 } 00070 00071 strcpy((char*)tempPath, [basePath cStringUsingEncoding:NSASCIIStringEncoding]); 00072 00073 [pool drain]; 00074 return tempPath; 00075 } 00076 00077 const GHOST_TUns8* GHOST_SystemPathsCocoa::getUserDir() const 00078 { 00079 static GHOST_TUns8 tempPath[512] = ""; 00080 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 00081 NSString *basePath; 00082 NSArray *paths; 00083 00084 paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES); 00085 00086 if ([paths count] > 0) 00087 basePath = [paths objectAtIndex:0]; 00088 else { 00089 [pool drain]; 00090 return NULL; 00091 } 00092 00093 strcpy((char*)tempPath, [basePath cStringUsingEncoding:NSASCIIStringEncoding]); 00094 00095 [pool drain]; 00096 return tempPath; 00097 } 00098 00099 const GHOST_TUns8* GHOST_SystemPathsCocoa::getBinaryDir() const 00100 { 00101 static GHOST_TUns8 tempPath[512] = ""; 00102 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 00103 NSString *basePath; 00104 00105 basePath = [[NSBundle mainBundle] bundlePath]; 00106 00107 if (basePath == nil) { 00108 [pool drain]; 00109 return NULL; 00110 } 00111 00112 strcpy((char*)tempPath, [basePath cStringUsingEncoding:NSASCIIStringEncoding]); 00113 00114 [pool drain]; 00115 return tempPath; 00116 } 00117 00118 void GHOST_SystemPathsCocoa::addToSystemRecentFiles(const char* filename) const 00119 { 00120 /* XXXXX TODO: Implementation for X11 if possible */ 00121 }