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:59 UTC

[8/8] git commit: CB-6249: Opportunistically resolve content urls to file

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();
 		}