cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject [39/50] git commit: CB-5915: Create documents directories if they don't exist
Date Mon, 10 Feb 2014 23:23:05 GMT
CB-5915: Create documents directories if they don't exist


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/commit/d5478e56
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/tree/d5478e56
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/diff/d5478e56

Branch: refs/heads/master
Commit: d5478e561277a80d54021c5ad5112a0b2bf06e6a
Parents: b68e127
Author: Ian Clelland <iclelland@chromium.org>
Authored: Tue Jan 28 11:42:21 2014 -0500
Committer: Ian Clelland <iclelland@chromium.org>
Committed: Tue Jan 28 11:42:21 2014 -0500

----------------------------------------------------------------------
 src/ios/CDVFile.m | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/d5478e56/src/ios/CDVFile.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVFile.m b/src/ios/CDVFile.m
index 847f858..b1925d0 100644
--- a/src/ios/CDVFile.m
+++ b/src/ios/CDVFile.m
@@ -198,9 +198,24 @@ NSString* const kCDVFilesystemURLPrefix = @"cdvfile";
                 @"File plugin configuration error: Please set iosPersistentFileLocation in
config.xml to one of \"library\" (for new applications) or \"compatibility\" (for compatibility
with previous versions)");
         }
 
-        [self registerFilesystem:[[CDVLocalFilesystem alloc] initWithName:@"temporary" root:self.appTempPath]];
+        NSError *error;
+        if ([[NSFileManager defaultManager] createDirectoryAtPath:self.appTempPath
+                                      withIntermediateDirectories:YES
+                                                       attributes:nil
+                                                            error:&error]) {
+            [self registerFilesystem:[[CDVLocalFilesystem alloc] initWithName:@"temporary"
root:self.appTempPath]];
+        } else {
+            NSLog(@"Unable to create temporary directory: %@", error);
+        }
         if ([location isEqualToString:@"library"]) {
-            [self registerFilesystem:[[CDVLocalFilesystem alloc] initWithName:@"persistent"
root:self.appLibraryPath]];
+            if ([[NSFileManager defaultManager] createDirectoryAtPath:self.appLibraryPath
+                                          withIntermediateDirectories:YES
+                                                           attributes:nil
+                                                                error:&error]) {
+                [self registerFilesystem:[[CDVLocalFilesystem alloc] initWithName:@"persistent"
root:self.appLibraryPath]];
+            } else {
+                NSLog(@"Unable to create library directory: %@", error);
+            }
         } else {
             // Compatibilty by default (if we're not embedded in a CDVViewController somehow.)
             /*
@@ -238,7 +253,6 @@ NSString* const kCDVFilesystemURLPrefix = @"cdvfile";
         self.rootDocsPath = [paths objectAtIndex:0];
         self.appDocsPath = [self.rootDocsPath stringByAppendingPathComponent:@"files"];
 
-
     }
 
     return self;


Mime
View raw message