Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'intern/ghost/intern/GHOST_SystemCocoa.mm')
-rw-r--r--intern/ghost/intern/GHOST_SystemCocoa.mm89
1 files changed, 89 insertions, 0 deletions
diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm
index 00b00c69cee..b093510c700 100644
--- a/intern/ghost/intern/GHOST_SystemCocoa.mm
+++ b/intern/ghost/intern/GHOST_SystemCocoa.mm
@@ -1780,3 +1780,92 @@ void GHOST_SystemCocoa::putClipboard(GHOST_TInt8 *buffer, bool selection) const
[pool drain];
}
+
+#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];
+ }
+
+ strcpy((char*)tempPath, [basePath cStringUsingEncoding:NSASCIIStringEncoding]);
+
+ [pool drain];
+ 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];
+ }
+
+ 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];
+ }
+
+ strcpy((char*)tempPath, [basePath cStringUsingEncoding:NSASCIIStringEncoding]);
+
+ [pool drain];
+ return tempPath;
+}