Return-Path: X-Original-To: apmail-cordova-commits-archive@www.apache.org Delivered-To: apmail-cordova-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 542F3106A8 for ; Tue, 28 Jan 2014 14:56:23 +0000 (UTC) Received: (qmail 49621 invoked by uid 500); 28 Jan 2014 14:56:23 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 49498 invoked by uid 500); 28 Jan 2014 14:56:21 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cordova.apache.org Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 49452 invoked by uid 99); 28 Jan 2014 14:56:20 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Jan 2014 14:56:20 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 9CF1F909DB6; Tue, 28 Jan 2014 14:56:20 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: ian@apache.org To: commits@cordova.apache.org Date: Tue, 28 Jan 2014 14:56:21 -0000 Message-Id: In-Reply-To: <05ffbcba90f54a70bdc312156bfb7271@git.apache.org> References: <05ffbcba90f54a70bdc312156bfb7271@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [2/2] 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/dev Commit: 40df005f6d4f3b4a984b3eae0275a16ac8f86513 Parents: 3fa16d0 Author: Ian Clelland Authored: Tue Jan 28 09:54:14 2014 -0500 Committer: Ian Clelland 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: - + 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 *)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"]; }