You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ia...@apache.org on 2014/04/04 19:11:52 UTC
[1/8] git commit: ios: Fix handling of file URLs with encoded spaces
Repository: cordova-plugin-file
Updated Branches:
refs/heads/dev e63190126 -> 3d7eb3e8e
ios: Fix handling of file URLs with encoded spaces
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/17a49917
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/tree/17a49917
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/diff/17a49917
Branch: refs/heads/dev
Commit: 17a49917d1f4ce91c64cce6cd4bf0a4f37a53480
Parents: e631901
Author: Ian Clelland <ic...@chromium.org>
Authored: Tue Apr 1 11:54:48 2014 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Thu Apr 3 09:18:42 2014 -0400
----------------------------------------------------------------------
src/ios/CDVLocalFilesystem.m | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/17a49917/src/ios/CDVLocalFilesystem.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVLocalFilesystem.m b/src/ios/CDVLocalFilesystem.m
index 5e3b15f..2b7f940 100644
--- a/src/ios/CDVLocalFilesystem.m
+++ b/src/ios/CDVLocalFilesystem.m
@@ -130,7 +130,7 @@
- (CDVFilesystemURL *)URLforFilesystemPath:(NSString *)path
{
- return [self URLforFullPath:[self fullPathForFileSystemPath:path]];
+ return [self URLforFullPath:[[self fullPathForFileSystemPath:path] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
}
[6/8] git commit: CB-6394: ios: Return ENCODING_ERR when fs name is
not valid
Posted by ia...@apache.org.
CB-6394: ios: Return ENCODING_ERR when fs name is not valid
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/ff592f69
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/tree/ff592f69
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/diff/ff592f69
Branch: refs/heads/dev
Commit: ff592f699c35ee3dc27f24dc785e1bf14798ed79
Parents: 37bedcb
Author: Ian Clelland <ic...@chromium.org>
Authored: Thu Apr 3 14:04:00 2014 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Fri Apr 4 13:11:11 2014 -0400
----------------------------------------------------------------------
src/ios/CDVFile.m | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/ff592f69/src/ios/CDVFile.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVFile.m b/src/ios/CDVFile.m
index e87e7dc..f4cbf30 100644
--- a/src/ios/CDVFile.m
+++ b/src/ios/CDVFile.m
@@ -439,7 +439,11 @@ NSString* const kCDVFilesystemURLPrefix = @"cdvfile";
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:ENCODING_ERR];
} else {
NSObject<CDVFileSystem> *fs = [self filesystemForURL:inputURI];
- result = [fs entryForLocalURI:inputURI];
+ if (fs == nil) {
+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:ENCODING_ERR];
+ } else {
+ result = [fs entryForLocalURI:inputURI];
+ }
}
[self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
}
[8/8] git commit: CB-6249: Opportunistically resolve content urls to
file
Posted by ia...@apache.org.
CB-6249: Opportunistically resolve content urls to file
This works on Android version pre-4.4. Another patch will be necessary for 4.4
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/3d7eb3e8
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/tree/3d7eb3e8
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/diff/3d7eb3e8
Branch: refs/heads/dev
Commit: 3d7eb3e8e61550ce230d41218314e7a5ebe29fce
Parents: 1789791
Author: Ian Clelland <ic...@chromium.org>
Authored: Fri Apr 4 12:32:59 2014 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Fri Apr 4 13:11:11 2014 -0400
----------------------------------------------------------------------
src/android/ContentFilesystem.java | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/3d7eb3e8/src/android/ContentFilesystem.java
----------------------------------------------------------------------
diff --git a/src/android/ContentFilesystem.java b/src/android/ContentFilesystem.java
index 52ec217..1a85de8 100644
--- a/src/android/ContentFilesystem.java
+++ b/src/android/ContentFilesystem.java
@@ -33,16 +33,23 @@ public class ContentFilesystem extends Filesystem {
public JSONObject getEntryForLocalURL(LocalFilesystemURL inputURL) throws IOException {
// Get the cursor to validate that the file exists
Cursor cursor = openCursorForURL(inputURL);
+ String filePath = null;
try {
if (cursor == null || !cursor.moveToFirst()) {
throw new FileNotFoundException();
}
+ filePath = filesystemPathForCursor(cursor);
} finally {
if (cursor != null)
cursor.close();
}
+ if (filePath == null) {
+ filePath = inputURL.URL.toString();
+ } else {
+ filePath = "file://" + filePath;
+ }
try {
- return makeEntryForPath(inputURL.fullPath, inputURL.filesystemName, false /*fp.isDirectory()*/, inputURL.URL.toString());
+ return makeEntryForPath(inputURL.fullPath, inputURL.filesystemName, false /*fp.isDirectory()*/, filePath);
} catch (JSONException e) {
throw new IOException();
}
[2/8] git commit: ios: Style: Don't make code look unreachable
Posted by ia...@apache.org.
ios: Style: Don't make code look unreachable
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/0af8049f
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/tree/0af8049f
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/diff/0af8049f
Branch: refs/heads/dev
Commit: 0af8049f0c36cba8d108bf713d6e71112427493b
Parents: 17a4991
Author: Ian Clelland <ic...@chromium.org>
Authored: Tue Apr 1 12:56:52 2014 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Fri Apr 4 09:27:47 2014 -0400
----------------------------------------------------------------------
src/ios/CDVLocalFilesystem.m | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/0af8049f/src/ios/CDVLocalFilesystem.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVLocalFilesystem.m b/src/ios/CDVLocalFilesystem.m
index 2b7f940..6b80ad3 100644
--- a/src/ios/CDVLocalFilesystem.m
+++ b/src/ios/CDVLocalFilesystem.m
@@ -121,8 +121,9 @@
- (CDVFilesystemURL *)URLforFullPath:(NSString *)fullPath
{
if (fullPath) {
- if ([fullPath hasPrefix:@"/"])
- return [CDVFilesystemURL fileSystemURLWithString:[NSString stringWithFormat:@"%@://localhost/%@%@", kCDVFilesystemURLPrefix, self.name, fullPath]];
+ if ([fullPath hasPrefix:@"/"]) {
+ return [CDVFilesystemURL fileSystemURLWithString:[NSString stringWithFormat:@"%@://localhost/%@%@", kCDVFilesystemURLPrefix, self.name, fullPath]];
+ }
return [CDVFilesystemURL fileSystemURLWithString:[NSString stringWithFormat:@"%@://localhost/%@/%@", kCDVFilesystemURLPrefix, self.name, fullPath]];
}
return nil;
[3/8] git commit: ios: Style: plugin initialization
Posted by ia...@apache.org.
ios: Style: plugin initialization
Use pluginInitialize rather than setViewController for initialization
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/23058965
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/tree/23058965
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/diff/23058965
Branch: refs/heads/dev
Commit: 2305896506e43394141dccb5feaa70b6e9b14910
Parents: 0af8049
Author: Ian Clelland <ic...@chromium.org>
Authored: Thu Apr 3 14:21:58 2014 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Fri Apr 4 09:27:48 2014 -0400
----------------------------------------------------------------------
src/ios/CDVFile.m | 81 +++++++++++++++++++++++---------------------------
1 file changed, 38 insertions(+), 43 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/23058965/src/ios/CDVFile.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVFile.m b/src/ios/CDVFile.m
index 02cc6a5..e87e7dc 100644
--- a/src/ios/CDVFile.m
+++ b/src/ios/CDVFile.m
@@ -199,57 +199,52 @@ NSString* const kCDVFilesystemURLPrefix = @"cdvfile";
}
}
-@synthesize viewController=_viewController;
-- (void)setViewController:(UIViewController *)newViewController
+- (void)pluginInitialize
{
- if (_viewController != newViewController) {
- _viewController = newViewController;
-
- NSString *location = nil;
- if([_viewController isKindOfClass:[CDVViewController class]]) {
- CDVViewController *vc = (CDVViewController *)_viewController;
- NSMutableDictionary *settings = vc.settings;
- location = [[settings objectForKey:@"iospersistentfilelocation"] lowercaseString];
- }
- if (location == nil) {
- // Compatibilty by default (if the config preference is not set, or
- // if we're not embedded in a CDVViewController somehow.)
- location = @"compatibility";
- }
+ NSString *location = nil;
+ if([self.viewController isKindOfClass:[CDVViewController class]]) {
+ CDVViewController *vc = (CDVViewController *)self.viewController;
+ NSMutableDictionary *settings = vc.settings;
+ location = [[settings objectForKey:@"iospersistentfilelocation"] lowercaseString];
+ }
+ if (location == nil) {
+ // Compatibilty by default (if the config preference is not set, or
+ // if we're not embedded in a CDVViewController somehow.)
+ location = @"compatibility";
+ }
- NSError *error;
- if ([[NSFileManager defaultManager] createDirectoryAtPath: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"]) {
+ if ([[NSFileManager defaultManager] createDirectoryAtPath:self.appLibraryPath
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"]) {
- 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 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
- * 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:[[CDVLocalFilesystem alloc] initWithName:@"persistent" root:self.appLibraryPath]];
} 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)");
+ NSLog(@"Unable to create library directory: %@", error);
}
- [self registerFilesystem:[[CDVAssetLibraryFilesystem alloc] initWithName:@"assets-library"]];
+ } 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
+ * 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]];
+ } 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"]];
}
[7/8] git commit: CB-6394: Add extra filesystem roots
Posted by ia...@apache.org.
CB-6394: Add extra filesystem roots
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/17897913
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/tree/17897913
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/diff/17897913
Branch: refs/heads/dev
Commit: 178979139161d1f1af5415698336448e2f9b9b96
Parents: 4d252e6
Author: Ian Clelland <ic...@chromium.org>
Authored: Thu Apr 3 13:26:25 2014 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Fri Apr 4 13:11:11 2014 -0400
----------------------------------------------------------------------
src/android/FileUtils.java | 49 +++++++++++++++++++++++++++++
src/ios/CDVFile.m | 69 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 118 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/17897913/src/android/FileUtils.java
----------------------------------------------------------------------
diff --git a/src/android/FileUtils.java b/src/android/FileUtils.java
index 44ea7c0..c34fd72 100644
--- a/src/android/FileUtils.java
+++ b/src/android/FileUtils.java
@@ -19,6 +19,7 @@
package org.apache.cordova.file;
import android.app.Activity;
+import android.content.Context;
import android.net.Uri;
import android.os.Environment;
import android.util.Base64;
@@ -42,6 +43,8 @@ import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URLDecoder;
import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
/**
* This class provides file and directory services to JavaScript.
@@ -90,7 +93,52 @@ public class FileUtils extends CordovaPlugin {
}
return null;
}
+
+ protected String[] getExtraFileSystemsPreference(Activity activity) {
+ String fileSystemsStr = activity.getIntent().getStringExtra("androidextrafilesystems");
+ if (fileSystemsStr == null) {
+ fileSystemsStr = "files,files-external,documents,sdcard,cache,cache-external,root";
+ }
+ return fileSystemsStr.split(",");
+ }
+
+ protected void registerExtraFileSystems(String[] filesystems, HashMap<String, String> availableFileSystems) {
+ HashSet<String> installedFileSystems = new HashSet<String>();
+
+ /* Register filesystems in order */
+ for (String fsName : filesystems) {
+ if (!installedFileSystems.contains(fsName)) {
+ String fsRoot = availableFileSystems.get(fsName);
+ if (fsRoot != null) {
+ File newRoot = new File(fsRoot);
+ if (newRoot.mkdirs() || newRoot.isDirectory()) {
+ registerFilesystem(new LocalFilesystem(fsName, cordova, fsRoot));
+ installedFileSystems.add(fsName);
+ } else {
+ Log.d(LOG_TAG, "Unable to create root dir for fileystem \"" + fsName + "\", skipping");
+ }
+ } else {
+ Log.d(LOG_TAG, "Unrecognized extra filesystem identifier: " + fsName);
+ }
+ }
+ }
+ }
+ protected HashMap<String, String> getAvailableFileSystems(Activity activity) {
+ Context context = activity.getApplicationContext();
+ HashMap<String, String> availableFileSystems = new HashMap<String,String>();
+
+ availableFileSystems.put("files", context.getFilesDir().getAbsolutePath());
+ availableFileSystems.put("files-external", context.getExternalFilesDir(null).getAbsolutePath());
+ availableFileSystems.put("documents", new File(context.getFilesDir(), "Documents").getAbsolutePath());
+ availableFileSystems.put("sdcard", Environment.getExternalStorageDirectory().getAbsolutePath());
+ availableFileSystems.put("cache", context.getCacheDir().getAbsolutePath());
+ availableFileSystems.put("cache-external", context.getExternalCacheDir().getAbsolutePath());
+ availableFileSystems.put("root", "/");
+
+ return availableFileSystems;
+ }
+
@Override
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
super.initialize(cordova, webView);
@@ -141,6 +189,7 @@ public class FileUtils extends CordovaPlugin {
this.registerFilesystem(new LocalFilesystem("persistent", cordova, persistentRoot));
this.registerFilesystem(new ContentFilesystem("content", cordova, webView));
+ registerExtraFileSystems(getExtraFileSystemsPreference(activity), getAvailableFileSystems(activity));
// Initialize static plugin reference for deprecated getEntry method
if (filePlugin == null) {
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/17897913/src/ios/CDVFile.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVFile.m b/src/ios/CDVFile.m
index f4cbf30..8d0a3d8 100644
--- a/src/ios/CDVFile.m
+++ b/src/ios/CDVFile.m
@@ -199,6 +199,71 @@ NSString* const kCDVFilesystemURLPrefix = @"cdvfile";
}
}
+- (NSArray *)getExtraFileSystemsPreference:(UIViewController *)vc
+{
+ NSString *filesystemsStr = nil;
+ if([self.viewController isKindOfClass:[CDVViewController class]]) {
+ CDVViewController *vc = (CDVViewController *)self.viewController;
+ NSDictionary *settings = [vc settings];
+ filesystemsStr = [settings[@"iosextrafilesystems"] lowercaseString];
+ }
+ if (!filesystemsStr) {
+ filesystemsStr = @"library,library-nosync,documents,documents-nosync,cache,bundle,root";
+ }
+ return [filesystemsStr componentsSeparatedByString:@","];
+}
+
+- (void)makeNonSyncable:(NSString*)path {
+ [[NSFileManager defaultManager] createDirectoryAtPath:path
+ withIntermediateDirectories:YES
+ attributes:nil
+ error:nil];
+ NSURL* url = [NSURL fileURLWithPath:path];
+ [url setResourceValue: [NSNumber numberWithBool: YES]
+ forKey: NSURLIsExcludedFromBackupKey error:nil];
+
+}
+
+- (void)registerExtraFileSystems:(NSArray *)filesystems fromAvailableSet:(NSDictionary *)availableFileSystems
+{
+ NSMutableSet *installedFilesystems = [[NSMutableSet alloc] initWithCapacity:7];
+
+ /* Build non-syncable directories as necessary */
+ for (NSString *nonSyncFS in @[@"library-nosync", @"documents-nosync"]) {
+ if ([filesystems containsObject:nonSyncFS]) {
+ [self makeNonSyncable:availableFileSystems[nonSyncFS]];
+ }
+ }
+
+ /* Register filesystems in order */
+ for (NSString *fsName in filesystems) {
+ if (![installedFilesystems containsObject:fsName]) {
+ NSString *fsRoot = availableFileSystems[fsName];
+ if (fsRoot) {
+ [filePlugin registerFilesystem:[[CDVLocalFilesystem alloc] initWithName:fsName root:fsRoot]];
+ [installedFilesystems addObject:fsName];
+ } else {
+ NSLog(@"Unrecognized extra filesystem identifier: %@", fsName);
+ }
+ }
+ }
+}
+
+- (NSDictionary *)getAvailableFileSystems
+{
+ NSString *libPath = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) objectAtIndex:0];
+ NSString *docPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
+ return @{
+ @"library": libPath,
+ @"library-nosync": [libPath stringByAppendingPathComponent:@"NoCloud"],
+ @"documents": docPath,
+ @"documents-nosync": [docPath stringByAppendingPathComponent:@"NoCloud"],
+ @"cache": [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) objectAtIndex:0],
+ @"bundle": [[NSBundle mainBundle] bundlePath],
+ @"root": @"/"
+ };
+}
+
- (void)pluginInitialize
{
NSString *location = nil;
@@ -245,6 +310,10 @@ 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:[[CDVAssetLibraryFilesystem alloc] initWithName:@"assets-library"]];
+
+ [self registerExtraFileSystems:[self getExtraFileSystemsPreference:self.viewController]
+ fromAvailableSet:[self getAvailableFileSystems]];
+
}
[4/8] git commit: CB-6393: Change behaviour of toURL and toNativeURL
Posted by ia...@apache.org.
CB-6393: Change behaviour of toURL and toNativeURL
Change Entry.toURL to return webview-usable URLs where possible.
Soft-deprecate Entry.toNativeURL
Introduce Entry.toInternalURL, for internal use for bridge-formatting Entry objects
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/37bedcb0
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/tree/37bedcb0
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/diff/37bedcb0
Branch: refs/heads/dev
Commit: 37bedcb0543bfc4f37517af32120b6ab9743315a
Parents: 2305896
Author: Ian Clelland <ic...@chromium.org>
Authored: Tue Apr 1 12:07:42 2014 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Fri Apr 4 09:28:06 2014 -0400
----------------------------------------------------------------------
plugin.xml | 3 ---
www/DirectoryEntry.js | 8 ++++----
www/Entry.js | 47 ++++++++++++++++++++++++++++++----------------
www/FileEntry.js | 2 +-
www/ios/Entry.js | 35 ----------------------------------
5 files changed, 36 insertions(+), 59 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/37bedcb0/plugin.xml
----------------------------------------------------------------------
diff --git a/plugin.xml b/plugin.xml
index b1f2729..61fad18 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -177,9 +177,6 @@ xmlns:android="http://schemas.android.com/apk/res/android"
<source-file src="src/ios/CDVAssetLibraryFilesystem.m" />
<!-- ios specific file apis -->
- <js-module src="www/ios/Entry.js" name="iosEntry">
- <merges target="window.Entry" />
- </js-module>
<js-module src="www/ios/FileSystem.js" name="iosFileSystem">
<merges target="window.FileSystem" />
</js-module>
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/37bedcb0/www/DirectoryEntry.js
----------------------------------------------------------------------
diff --git a/www/DirectoryEntry.js b/www/DirectoryEntry.js
index 417c97e..8b98283 100644
--- a/www/DirectoryEntry.js
+++ b/www/DirectoryEntry.js
@@ -45,7 +45,7 @@ utils.extend(DirectoryEntry, Entry);
* Creates a new DirectoryReader to read entries from this directory
*/
DirectoryEntry.prototype.createReader = function() {
- return new DirectoryReader(this.toURL());
+ return new DirectoryReader(this.toInternalURL());
};
/**
@@ -66,7 +66,7 @@ DirectoryEntry.prototype.getDirectory = function(path, options, successCallback,
var fail = errorCallback && function(code) {
errorCallback(new FileError(code));
};
- exec(win, fail, "File", "getDirectory", [this.filesystem.__format__(this.fullPath), path, options]);
+ exec(win, fail, "File", "getDirectory", [this.toInternalURL(), path, options]);
};
/**
@@ -80,7 +80,7 @@ DirectoryEntry.prototype.removeRecursively = function(successCallback, errorCall
var fail = errorCallback && function(code) {
errorCallback(new FileError(code));
};
- exec(successCallback, fail, "File", "removeRecursively", [this.filesystem.__format__(this.fullPath)]);
+ exec(successCallback, fail, "File", "removeRecursively", [this.toInternalURL()]);
};
/**
@@ -102,7 +102,7 @@ DirectoryEntry.prototype.getFile = function(path, options, successCallback, erro
var fail = errorCallback && function(code) {
errorCallback(new FileError(code));
};
- exec(win, fail, "File", "getFile", [this.filesystem.__format__(this.fullPath), path, options]);
+ exec(win, fail, "File", "getFile", [this.toInternalURL(), path, options]);
};
module.exports = DirectoryEntry;
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/37bedcb0/www/Entry.js
----------------------------------------------------------------------
diff --git a/www/Entry.js b/www/Entry.js
index b025334..d143d32 100644
--- a/www/Entry.js
+++ b/www/Entry.js
@@ -71,7 +71,7 @@ Entry.prototype.getMetadata = function(successCallback, errorCallback) {
var fail = errorCallback && function(code) {
errorCallback(new FileError(code));
};
- exec(success, fail, "File", "getMetadata", [this.filesystem.__format__(this.fullPath)]);
+ exec(success, fail, "File", "getMetadata", [this.toInternalURL()]);
};
/**
@@ -86,7 +86,7 @@ Entry.prototype.getMetadata = function(successCallback, errorCallback) {
*/
Entry.prototype.setMetadata = function(successCallback, errorCallback, metadataObject) {
argscheck.checkArgs('FFO', 'Entry.setMetadata', arguments);
- exec(successCallback, errorCallback, "File", "setMetadata", [this.filesystem.__format__(this.fullPath), metadataObject]);
+ exec(successCallback, errorCallback, "File", "setMetadata", [this.toInternalURL(), metadataObject]);
};
/**
@@ -106,7 +106,7 @@ Entry.prototype.moveTo = function(parent, newName, successCallback, errorCallbac
var fail = errorCallback && function(code) {
errorCallback(new FileError(code));
};
- var srcURL = this.filesystem.__format__(this.fullPath),
+ var srcURL = this.toInternalURL(),
// entry name
name = newName || this.name,
success = function(entry) {
@@ -125,7 +125,7 @@ Entry.prototype.moveTo = function(parent, newName, successCallback, errorCallbac
};
// copy
- exec(success, fail, "File", "moveTo", [srcURL, parent.filesystem.__format__(parent.fullPath), name]);
+ exec(success, fail, "File", "moveTo", [srcURL, parent.toInternalURL(), name]);
};
/**
@@ -145,7 +145,7 @@ Entry.prototype.copyTo = function(parent, newName, successCallback, errorCallbac
var fail = errorCallback && function(code) {
errorCallback(new FileError(code));
};
- var srcURL = this.filesystem.__format__(this.fullPath),
+ var srcURL = this.toInternalURL(),
// entry name
name = newName || this.name,
// success callback
@@ -165,26 +165,42 @@ Entry.prototype.copyTo = function(parent, newName, successCallback, errorCallbac
};
// copy
- exec(success, fail, "File", "copyTo", [srcURL, parent.filesystem.__format__(parent.fullPath), name]);
+ exec(success, fail, "File", "copyTo", [srcURL, parent.toInternalURL(), name]);
};
/**
- * Return a URL that can be used to identify this entry.
+ * Return a URL that can be passed across the bridge to identify this entry.
*/
-Entry.prototype.toURL = function() {
+Entry.prototype.toInternalURL = function() {
if (this.filesystem && this.filesystem.__format__) {
return this.filesystem.__format__(this.fullPath);
}
- // fullPath attribute contains the full URL
- return "file://localhost" + this.fullPath;
};
/**
- * Return a URL that can be used to as the src attribute of a <video> or
- * <audio> tag, in case it is different from the URL returned by .toURL().
+ * Return a URL that can be used to identify this entry.
+ * Use a URL that can be used to as the src attribute of a <video> or
+ * <audio> tag. If that is not possible, construct a cdvfile:// URL.
+ */
+Entry.prototype.toURL = function() {
+ if (this.nativeURL) {
+ return this.nativeURL;
+ }
+ // fullPath attribute may contain the full URL in the case that
+ // toInternalURL fails.
+ return this.toInternalURL() || "file://localhost" + this.fullPath;
+};
+
+/**
+ * Backwards-compatibility: In v1.0.0 - 1.0.2, .toURL would only return a
+ * cdvfile:// URL, and this method was necessary to obtain URLs usable by the
+ * webview.
+ * See CB-6051, CB-6106, CB-6117, CB-6152, CB-6199, CB-6201, CB-6243, CB-6249,
+ * and CB-6300.
*/
Entry.prototype.toNativeURL = function() {
- return this.nativeURL || this.toURL();
+ console.log("DEPRECATED: Update your code to use 'toURL'");
+ return this.toURL();
};
/**
@@ -195,7 +211,6 @@ Entry.prototype.toNativeURL = function() {
*/
Entry.prototype.toURI = function(mimeType) {
console.log("DEPRECATED: Update your code to use 'toURL'");
- // fullPath attribute contains the full URI
return this.toURL();
};
@@ -212,7 +227,7 @@ Entry.prototype.remove = function(successCallback, errorCallback) {
var fail = errorCallback && function(code) {
errorCallback(new FileError(code));
};
- exec(successCallback, fail, "File", "remove", [this.filesystem.__format__(this.fullPath)]);
+ exec(successCallback, fail, "File", "remove", [this.toInternalURL()]);
};
/**
@@ -232,7 +247,7 @@ Entry.prototype.getParent = function(successCallback, errorCallback) {
var fail = errorCallback && function(code) {
errorCallback(new FileError(code));
};
- exec(win, fail, "File", "getParent", [this.filesystem.__format__(this.fullPath)]);
+ exec(win, fail, "File", "getParent", [this.toInternalURL()]);
};
module.exports = Entry;
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/37bedcb0/www/FileEntry.js
----------------------------------------------------------------------
diff --git a/www/FileEntry.js b/www/FileEntry.js
index ac11d06..59a9dc3 100644
--- a/www/FileEntry.js
+++ b/www/FileEntry.js
@@ -66,7 +66,7 @@ FileEntry.prototype.createWriter = function(successCallback, errorCallback) {
* @param {Function} errorCallback is called with a FileError
*/
FileEntry.prototype.file = function(successCallback, errorCallback) {
- var localURL = this.filesystem.__format__(this.fullPath);
+ var localURL = this.toInternalURL();
var win = successCallback && function(f) {
var file = new File(f.name, localURL, f.type, f.lastModifiedDate, f.size);
successCallback(file);
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/37bedcb0/www/ios/Entry.js
----------------------------------------------------------------------
diff --git a/www/ios/Entry.js b/www/ios/Entry.js
deleted file mode 100644
index b76162d..0000000
--- a/www/ios/Entry.js
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-module.exports = {
- toURL:function() {
- // TODO: refactor path in a cross-platform way so we can eliminate
- // these kinds of platform-specific hacks.
- if (this.filesystem && this.filesystem.__format__) {
- return this.filesystem.__format__(this.fullPath);
- }
- return "file://localhost" + this.fullPath;
- },
- toURI: function() {
- console.log("DEPRECATED: Update your code to use 'toURL'");
- return this.toURL();
- }
-};
[5/8] git commit: CB-6394: Fix file resolution for the device root
case
Posted by ia...@apache.org.
CB-6394: Fix file resolution for the device root case
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/4d252e61
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/tree/4d252e61
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/diff/4d252e61
Branch: refs/heads/dev
Commit: 4d252e6141ffd1dcf68e191e3de6e3a5019041a7
Parents: ff592f6
Author: Ian Clelland <ic...@chromium.org>
Authored: Thu Apr 3 13:25:42 2014 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Fri Apr 4 13:11:11 2014 -0400
----------------------------------------------------------------------
src/android/LocalFilesystem.java | 2 +-
src/ios/CDVLocalFilesystem.m | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/4d252e61/src/android/LocalFilesystem.java
----------------------------------------------------------------------
diff --git a/src/android/LocalFilesystem.java b/src/android/LocalFilesystem.java
index ac7e189..2ea058a 100644
--- a/src/android/LocalFilesystem.java
+++ b/src/android/LocalFilesystem.java
@@ -38,7 +38,7 @@ public class LocalFilesystem extends Filesystem {
if (questionMark >= 0) {
path = path.substring(0, questionMark);
}
- if (path.endsWith("/")) {
+ if (path.length() > 1 && path.endsWith("/")) {
path = path.substring(0, path.length()-1);
}
return path;
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/4d252e61/src/ios/CDVLocalFilesystem.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVLocalFilesystem.m b/src/ios/CDVLocalFilesystem.m
index 6b80ad3..3682ab1 100644
--- a/src/ios/CDVLocalFilesystem.m
+++ b/src/ios/CDVLocalFilesystem.m
@@ -99,7 +99,7 @@
NSString *path = nil;
NSString *strippedFullPath = [self stripQueryParametersFromPath:fullPath];
path = [NSString stringWithFormat:@"%@%@", self.fsRoot, strippedFullPath];
- if ([path hasSuffix:@"/"]) {
+ if ([path length] > 1 && [path hasSuffix:@"/"]) {
path = [path substringToIndex:([path length]-1)];
}
return path;