cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From i..@apache.org
Subject git commit: CB-6050: Create instance method for returning a FileEntry structure given a device file path
Date Tue, 18 Feb 2014 20:25:43 GMT
Repository: cordova-plugin-file
Updated Branches:
  refs/heads/dev c56b33035 -> af70ff4e6


CB-6050: Create instance method for returning a FileEntry structure given a device file path


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

Branch: refs/heads/dev
Commit: af70ff4e65d6a90bfc03ac3b7561624d6552daef
Parents: c56b330
Author: Ian Clelland <iclelland@chromium.org>
Authored: Tue Feb 18 15:04:58 2014 -0500
Committer: Ian Clelland <iclelland@chromium.org>
Committed: Tue Feb 18 15:04:58 2014 -0500

----------------------------------------------------------------------
 src/android/FileUtils.java | 29 +++++++++++++++++++++--------
 1 file changed, 21 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/af70ff4e/src/android/FileUtils.java
----------------------------------------------------------------------
diff --git a/src/android/FileUtils.java b/src/android/FileUtils.java
index ca643b3..f7eeaae 100644
--- a/src/android/FileUtils.java
+++ b/src/android/FileUtils.java
@@ -752,6 +752,26 @@ public class FileUtils extends CordovaPlugin {
         return fs;
     }
 
+   /**
+     * Returns a JSON object representing the given File. Internal APIs should be modified
+     * to use URLs instead of raw FS paths wherever possible, when interfacing with this
plugin.
+     *
+     * @param file the File to convert
+     * @return a JSON representation of the given File
+     * @throws JSONException
+     */
+    public JSONObject getEntryForFile(File file) throws JSONException {
+        JSONObject entry;
+
+        for (Filesystem fs : filesystems) {
+             entry = fs.makeEntryForFile(file);
+             if (entry != null) {
+                 return entry;
+             }
+        }
+        return null;
+    }
+
     /**
      * Returns a JSON object representing the given File. Deprecated, as this is only used
by
      * FileTransfer, and because it is a static method that should really be an instance
method,
@@ -764,15 +784,8 @@ public class FileUtils extends CordovaPlugin {
      */
     @Deprecated
     public static JSONObject getEntry(File file) throws JSONException {
-		JSONObject entry;
-		
  		if (getFilePlugin() != null) {
- 			for (Filesystem fs:getFilePlugin().filesystems) {
- 				entry = fs.makeEntryForFile(file);
- 				if (entry != null) {
- 					return entry;
- 				}
-			}
+             return getFilePlugin().getEntryForFile(file);
 		}
 		return null;
     }


Mime
View raw message