[sword-svn] r3413 - trunk/bindings/objc/src/services

mdbergmann at crosswire.org mdbergmann at crosswire.org
Tue Mar 1 14:48:15 MST 2016


Author: mdbergmann
Date: 2016-03-01 14:48:15 -0700 (Tue, 01 Mar 2016)
New Revision: 3413

Modified:
   trunk/bindings/objc/src/services/Configuration.h
   trunk/bindings/objc/src/services/Configuration.m
   trunk/bindings/objc/src/services/OSXConfiguration.h
   trunk/bindings/objc/src/services/OSXConfiguration.m
Log:
adapted file path for sandbox environment.

Modified: trunk/bindings/objc/src/services/Configuration.h
===================================================================
--- trunk/bindings/objc/src/services/Configuration.h	2016-03-01 21:41:32 UTC (rev 3412)
+++ trunk/bindings/objc/src/services/Configuration.h	2016-03-01 21:48:15 UTC (rev 3413)
@@ -20,6 +20,7 @@
 - (NSString *)osVersion;
 - (NSString *)bundleVersion;
 - (NSString *)defaultModulePath;
+- (NSString *)defaultAppSupportPath;
 - (NSString *)tempFolder;
 - (NSString *)logFile;
 
@@ -35,6 +36,7 @@
 - (NSString *)osVersion;
 - (NSString *)bundleVersion;
 - (NSString *)defaultModulePath;
+- (NSString *)defaultAppSupportPath;
 - (NSString *)tempFolder;
 - (NSString *)logFile;
 

Modified: trunk/bindings/objc/src/services/Configuration.m
===================================================================
--- trunk/bindings/objc/src/services/Configuration.m	2016-03-01 21:41:32 UTC (rev 3412)
+++ trunk/bindings/objc/src/services/Configuration.m	2016-03-01 21:48:15 UTC (rev 3413)
@@ -38,6 +38,7 @@
 - (NSString *)osVersion {return [impl osVersion];}
 - (NSString *)bundleVersion {return [impl bundleVersion];}
 - (NSString *)defaultModulePath {return [impl defaultModulePath];}
+- (NSString *)defaultAppSupportPath {return [impl defaultAppSupportPath];}
 - (NSString *)tempFolder {return [impl tempFolder];}
 - (NSString *)logFile {return [impl logFile];}
 

Modified: trunk/bindings/objc/src/services/OSXConfiguration.h
===================================================================
--- trunk/bindings/objc/src/services/OSXConfiguration.h	2016-03-01 21:41:32 UTC (rev 3412)
+++ trunk/bindings/objc/src/services/OSXConfiguration.h	2016-03-01 21:48:15 UTC (rev 3413)
@@ -15,6 +15,7 @@
 - (NSString *)osVersion;
 - (NSString *)bundleVersion;
 - (NSString *)defaultModulePath;
+- (NSString *)defaultAppSupportPath;
 - (NSString *)tempFolder;
 - (NSString *)logFile;
 

Modified: trunk/bindings/objc/src/services/OSXConfiguration.m
===================================================================
--- trunk/bindings/objc/src/services/OSXConfiguration.m	2016-03-01 21:41:32 UTC (rev 3412)
+++ trunk/bindings/objc/src/services/OSXConfiguration.m	2016-03-01 21:48:15 UTC (rev 3413)
@@ -22,15 +22,35 @@
 - (NSString *)defaultModulePath {
     NSArray *urls = [[NSFileManager defaultManager] URLsForDirectory:NSApplicationSupportDirectory inDomains:NSUserDomainMask];
     if(urls.count > 0) {
-        return [[(NSURL *)urls[0] path] stringByAppendingPathComponent:@"Sword"];
+        NSString *folder = [[(NSURL *)urls[0] path] stringByAppendingPathComponent:@"Sword"];
+        if(![[NSFileManager defaultManager] fileExistsAtPath:folder]) {
+            [[NSFileManager defaultManager] createDirectoryAtPath:folder withIntermediateDirectories:NO attributes:nil error:NULL];
+        }
+        return folder;
     }
     return nil;
 }
 
+- (NSString *)defaultAppSupportPath {
+    NSArray *urls = [[NSFileManager defaultManager] URLsForDirectory:NSApplicationSupportDirectory inDomains:NSUserDomainMask];
+    if(urls.count > 0) {
+        NSString *folder = [[(NSURL *)urls[0] path] stringByAppendingPathComponent:@"ObjCSword"];
+        if(![[NSFileManager defaultManager] fileExistsAtPath:folder]) {
+            [[NSFileManager defaultManager] createDirectoryAtPath:folder withIntermediateDirectories:NO attributes:nil error:NULL];
+        }
+        return folder;
+    }
+    return nil;
+}
+
 - (NSString *)tempFolder {
     NSArray *urls = [[NSFileManager defaultManager] URLsForDirectory:NSCachesDirectory inDomains:NSUserDomainMask];
     if(urls.count > 0) {
-        return [[(NSURL *)urls[0] path] stringByAppendingPathComponent:@"ObjCSword"];
+        NSString *folder = [[(NSURL *)urls[0] path] stringByAppendingPathComponent:@"ObjCSword"];
+        if(![[NSFileManager defaultManager] fileExistsAtPath:folder]) {
+            [[NSFileManager defaultManager] createDirectoryAtPath:folder withIntermediateDirectories:NO attributes:nil error:NULL];
+        }
+        return folder;
     }
     return nil;
 }




More information about the sword-cvs mailing list