You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by st...@apache.org on 2014/02/11 00:23:02 UTC

[36/50] git commit: CB-5915: ios: Update config preference (and docs) to match issue

CB-5915: ios: Update config preference (and docs) to match issue


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/40df005f
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/tree/40df005f
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/diff/40df005f

Branch: refs/heads/master
Commit: 40df005f6d4f3b4a984b3eae0275a16ac8f86513
Parents: 3fa16d0
Author: Ian Clelland <ic...@chromium.org>
Authored: Tue Jan 28 09:54:14 2014 -0500
Committer: Ian Clelland <ic...@chromium.org>
Committed: Tue Jan 28 09:54:14 2014 -0500

----------------------------------------------------------------------
 doc/index.md      |  8 +++-----
 src/ios/CDVFile.h |  2 ++
 src/ios/CDVFile.m | 20 ++++++++++++++------
 3 files changed, 19 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/40df005f/doc/index.md
----------------------------------------------------------------------
diff --git a/doc/index.md b/doc/index.md
index 003ba0e..dd36dc7 100644
--- a/doc/index.md
+++ b/doc/index.md
@@ -112,18 +112,16 @@ add one of these two lines to config.xml:
 
     <preference name="iosPersistentFileLocation" value="Library" />
 
-    <preference name="iosPersistentFileLocation" value="Documents" />
+    <preference name="iosPersistentFileLocation" value="Compatibility" />
 
 Without this line, the File plugin will not initialize, and your application
 will not start.
 
 If your application has previously been shipped to users, using an older (pre-
 1.0) version of this plugin, and has stored files in the persistent filesystem,
-then you should set the preference to "Documents". Switching the location to
+then you should set the preference to "Compatibility". Switching the location to
 "Library" would mean that existing users who upgrade their application would be
 unable to access their previously-stored files.
 
 If your application is new, or has never previously stored files in the
-persistent filesystem, then the "Library" setting is generally recommended,
-unless your application's purpose is to generate document files for users to
-consume externally.
+persistent filesystem, then the "Library" setting is generally recommended.

http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/40df005f/src/ios/CDVFile.h
----------------------------------------------------------------------
diff --git a/src/ios/CDVFile.h b/src/ios/CDVFile.h
index 477fad7..751b9d4 100644
--- a/src/ios/CDVFile.h
+++ b/src/ios/CDVFile.h
@@ -87,6 +87,7 @@ typedef int CDVFileError;
 @end
 
 @interface CDVFile : CDVPlugin {
+    NSString* rootDocsPath;
     NSString* appDocsPath;
     NSString* appLibraryPath;
     NSString* appTempPath;
@@ -136,6 +137,7 @@ typedef int CDVFileError;
 /* Internal methods for testing */
 - (void)_getLocalFilesystemPath:(CDVInvokedUrlCommand*)command;
 
+@property (nonatomic, strong) NSString* rootDocsPath;
 @property (nonatomic, strong) NSString* appDocsPath;
 @property (nonatomic, strong) NSString* appLibraryPath;
 @property (nonatomic, strong) NSString* appTempPath;

http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/40df005f/src/ios/CDVFile.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVFile.m b/src/ios/CDVFile.m
index e685929..847f858 100644
--- a/src/ios/CDVFile.m
+++ b/src/ios/CDVFile.m
@@ -153,7 +153,7 @@ NSString* const kCDVFilesystemURLPrefix = @"cdvfile";
 
 @implementation CDVFile
 
-@synthesize appDocsPath, appLibraryPath, appTempPath, userHasAllowed, fileSystems=fileSystems_;
+@synthesize rootDocsPath, appDocsPath, appLibraryPath, appTempPath, userHasAllowed, fileSystems=fileSystems_;
 
 - (void)registerFilesystem:(NSObject<CDVFileSystem> *)fs {
     [fileSystems_ addObject:fs];
@@ -194,8 +194,8 @@ NSString* const kCDVFilesystemURLPrefix = @"cdvfile";
             NSMutableDictionary *settings = vc.settings;
             location = [[settings objectForKey:@"iospersistentfilelocation"] lowercaseString];
             NSAssert(
-                [location isEqualToString:@"library"] || [location isEqualToString:@"documents"],
-                @"File plugin configuration error: Please set ios-persistent-file-location in config.xml to one of \"library\" (for new applications) or \"documents\" (for compatibility with previous versions)");
+                [location isEqualToString:@"library"] || [location isEqualToString:@"compatibility"],
+                @"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]];
@@ -203,7 +203,14 @@ NSString* const kCDVFilesystemURLPrefix = @"cdvfile";
             [self registerFilesystem:[[CDVLocalFilesystem alloc] initWithName:@"persistent" root:self.appLibraryPath]];
         } else {
             // Compatibilty by default (if we're not embedded in a CDVViewController somehow.)
-            [self registerFilesystem:[[CDVLocalFilesystem alloc] initWithName:@"persistent" root:self.appDocsPath]];
+            /*
+             *  Fall-back to compatibility mode -- this is the logic implemented in
+             *  earlier versions of this plugin, and should be maintained here so
+             *  that apps which were originally deployed with older versions of the
+             *  plugin can continue to provide access to files stored under those
+             *  versions.
+             */
+            [self registerFilesystem:[[CDVLocalFilesystem alloc] initWithName:@"persistent" root:self.rootDocsPath]];
         }
         [self registerFilesystem:[[CDVAssetLibraryFilesystem alloc] initWithName:@"assets-library"]];
     }
@@ -221,14 +228,15 @@ NSString* const kCDVFilesystemURLPrefix = @"cdvfile";
 
         // Get the Library directory path
         NSArray* paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
-        self.appLibraryPath = [paths objectAtIndex:0];
+        self.appLibraryPath = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"files"];
 
         // Get the Temporary directory path
         self.appTempPath = [NSTemporaryDirectory()stringByStandardizingPath];   // remove trailing slash from NSTemporaryDirectory()
 
         // Get the Documents directory path
         paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
-        self.appDocsPath = [paths objectAtIndex:0];
+        self.rootDocsPath = [paths objectAtIndex:0];
+        self.appDocsPath = [self.rootDocsPath stringByAppendingPathComponent:@"files"];
 
 
     }