cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From i..@apache.org
Subject [18/19] git commit: Android: Add method for testing backwards-compatibility of filetransfer plugin
Date Fri, 13 Dec 2013 16:19:00 GMT
Android: Add method for testing backwards-compatibility of filetransfer plugin


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

Branch: refs/heads/dev
Commit: 83a867cc7811fa2b0aff5f340c8a1122ee40e6e2
Parents: 4c44780
Author: Ian Clelland <iclelland@chromium.org>
Authored: Wed Dec 11 11:26:32 2013 -0500
Committer: Ian Clelland <iclelland@chromium.org>
Committed: Fri Dec 13 11:16:37 2013 -0500

----------------------------------------------------------------------
 src/android/FileUtils.java | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/83a867cc/src/android/FileUtils.java
----------------------------------------------------------------------
diff --git a/src/android/FileUtils.java b/src/android/FileUtils.java
index 1f345fe..7e852b5 100644
--- a/src/android/FileUtils.java
+++ b/src/android/FileUtils.java
@@ -361,12 +361,38 @@ public class FileUtils extends CordovaPlugin {
                 }
             },callbackContext);
         }
+        else if (action.equals("_getLocalFilesystemPath")) {
+            // Internal method for testing: Get the on-disk location of a local filesystem
url.
+            // [Currently used for testing file-transfer]
+            final String localURLstr = args.getString(0);
+            threadhelper( new FileOp( ){
+                public void run() throws FileNotFoundException, JSONException, MalformedURLException
{
+                    String fname = _filesystemPathForURL(localURLstr);
+                    callbackContext.success(fname);
+                }
+            },callbackContext);
+        }
         else {
             return false;
         }
         return true;
     }
 
+    /* Internal method for testing: Get the on-disk location of a local filesystem url.
+     */
+    protected String _filesystemPathForURL(String localURLstr) throws MalformedURLException
{
+        try {
+            LocalFilesystemURL inputURL = new LocalFilesystemURL(localURLstr);
+            Filesystem fs = this.filesystemForURL(inputURL);
+            if (fs == null) {
+                throw new MalformedURLException("No installed handlers for this URL");
+            }
+            return fs.filesystemPathForURL(inputURL);
+        } catch (IllegalArgumentException e) {
+            throw new MalformedURLException("Unrecognized filesystem URL");
+        }
+    }
+
     /* helper to execute functions async and handle the result codes
      *
      */


Mime
View raw message