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 2F5DB10AAA for ; Wed, 5 Feb 2014 21:37:50 +0000 (UTC) Received: (qmail 61229 invoked by uid 500); 5 Feb 2014 21:37:49 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 61213 invoked by uid 500); 5 Feb 2014 21:37:49 -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 61199 invoked by uid 99); 5 Feb 2014 21:37:48 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 05 Feb 2014 21:37:48 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 7467D91CDFA; Wed, 5 Feb 2014 21:37:48 +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: Wed, 05 Feb 2014 21:37:48 -0000 Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: [1/2] git commit: CB-5915: CB-5916: Reorganize preference code to make defaults possible Updated Branches: refs/heads/dev f4ed88d8d -> 3c0ba7208 CB-5915: CB-5916: Reorganize preference code to make defaults possible 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/d8c5e5dc Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/tree/d8c5e5dc Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/diff/d8c5e5dc Branch: refs/heads/dev Commit: d8c5e5dc8063658c863d4f5f13e18fdcf6383804 Parents: f4ed88d Author: Ian Clelland Authored: Wed Feb 5 16:23:39 2014 -0500 Committer: Ian Clelland Committed: Wed Feb 5 16:23:39 2014 -0500 ---------------------------------------------------------------------- src/android/FileUtils.java | 49 +++++++++++++++++++++-------------------- src/ios/CDVFile.m | 6 +++-- 2 files changed, 29 insertions(+), 26 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/d8c5e5dc/src/android/FileUtils.java ---------------------------------------------------------------------- diff --git a/src/android/FileUtils.java b/src/android/FileUtils.java index 26e3479..8e6646b 100644 --- a/src/android/FileUtils.java +++ b/src/android/FileUtils.java @@ -104,31 +104,30 @@ public class FileUtils extends CordovaPlugin { String packageName = activity.getPackageName(); String location = activity.getIntent().getStringExtra("androidpersistentfilelocation"); - if (location == null || !(location.equalsIgnoreCase("internal") || location.equalsIgnoreCase("compatibility"))) { - Log.e(LOG_TAG, "File plugin configuration error: Please set AndroidPersistentFileLocation in config.xml to one of \"internal\" (for new applications) or \"compatibility\" (for compatibility with previous versions)"); - activity.finish(); - } - else { - if (location.equalsIgnoreCase("internal")) { - persistentRoot = activity.getFilesDir().getAbsolutePath() + "/files/"; - tempRoot = activity.getCacheDir().getAbsolutePath(); + if ("internal".equalsIgnoreCase(location)) { + persistentRoot = activity.getFilesDir().getAbsolutePath() + "/files/"; + tempRoot = activity.getCacheDir().getAbsolutePath(); + this.configured = true; + } else if ("compatibility".equalsIgnoreCase(location)) { + /* + * 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. + */ + if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { + persistentRoot = Environment.getExternalStorageDirectory().getAbsolutePath(); + tempRoot = Environment.getExternalStorageDirectory().getAbsolutePath() + + "/Android/data/" + packageName + "/cache/"; } else { - /* - * 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. - */ - if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { - persistentRoot = Environment.getExternalStorageDirectory().getAbsolutePath(); - tempRoot = Environment.getExternalStorageDirectory().getAbsolutePath() + - "/Android/data/" + packageName + "/cache/"; - } else { - persistentRoot = "/data/data/" + packageName; - tempRoot = "/data/data/" + packageName + "/cache/"; - } + persistentRoot = "/data/data/" + packageName; + tempRoot = "/data/data/" + packageName + "/cache/"; } + this.configured = true; + } + + if (this.configured) { // Create the directories if they don't exist. new File(tempRoot).mkdirs(); new File(persistentRoot).mkdirs(); @@ -141,12 +140,14 @@ public class FileUtils extends CordovaPlugin { this.registerFilesystem(new LocalFilesystem("persistent", cordova, persistentRoot)); this.registerFilesystem(new ContentFilesystem("content", cordova, webView)); - this.configured = true; // Initialize static plugin reference for deprecated getEntry method if (filePlugin == null) { FileUtils.filePlugin = this; } + } else { + Log.e(LOG_TAG, "File plugin configuration error: Please set AndroidPersistentFileLocation in config.xml to one of \"internal\" (for new applications) or \"compatibility\" (for compatibility with previous versions)"); + activity.finish(); } } http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/d8c5e5dc/src/ios/CDVFile.m ---------------------------------------------------------------------- diff --git a/src/ios/CDVFile.m b/src/ios/CDVFile.m index b1925d0..d07cc9c 100644 --- a/src/ios/CDVFile.m +++ b/src/ios/CDVFile.m @@ -216,8 +216,7 @@ NSString* const kCDVFilesystemURLPrefix = @"cdvfile"; } else { NSLog(@"Unable to create library directory: %@", error); } - } else { - // Compatibilty by default (if we're not embedded in a CDVViewController somehow.) + } else if ([location isEqualToString:@"compatibility"]) { /* * Fall-back to compatibility mode -- this is the logic implemented in * earlier versions of this plugin, and should be maintained here so @@ -226,6 +225,9 @@ NSString* const kCDVFilesystemURLPrefix = @"cdvfile"; * versions. */ [self registerFilesystem:[[CDVLocalFilesystem alloc] initWithName:@"persistent" root:self.rootDocsPath]]; + } else { + NSAssert(false, + @"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:[[CDVAssetLibraryFilesystem alloc] initWithName:@"assets-library"]]; }