incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bcur...@apache.org
Subject [3/16] android commit: Use strings not objects
Date Fri, 17 Feb 2012 22:58:02 GMT
Use strings not objects


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/commit/d87ee719
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/tree/d87ee719
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/diff/d87ee719

Branch: refs/heads/master
Commit: d87ee719a301e8603518b75cb3a3c17666d18f63
Parents: a52ba37
Author: Fil Maj <filip.maj@nitobi.com>
Authored: Thu Feb 16 18:17:25 2012 -0800
Committer: Fil Maj <filip.maj@nitobi.com>
Committed: Thu Feb 16 18:17:25 2012 -0800

----------------------------------------------------------------------
 framework/src/org/apache/cordova/FileUtils.java |   20 ++++++++++++++---
 1 files changed, 16 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/d87ee719/framework/src/org/apache/cordova/FileUtils.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/FileUtils.java b/framework/src/org/apache/cordova/FileUtils.java
index 73a1486..c148967 100755
--- a/framework/src/org/apache/cordova/FileUtils.java
+++ b/framework/src/org/apache/cordova/FileUtils.java
@@ -185,11 +185,11 @@ public class FileUtils extends Plugin {
                 }
             }
             else if (action.equals("moveTo")) {
-                JSONObject entry = transferTo(args.getString(0), args.getJSONObject(1), args.optString(2),
true);
+                JSONObject entry = transferTo(args.getString(0), args.getString(1), args.getString(2),
true);
                 return new PluginResult(status, entry);
             }
             else if (action.equals("copyTo")) {
-                JSONObject entry = transferTo(args.getString(0), args.getJSONObject(1), args.optString(2),
false);
+                JSONObject entry = transferTo(args.getString(0), args.getString(1), args.getString(2),
false);
                 return new PluginResult(status, entry);
             }
             else if (action.equals("readEntries")) {
@@ -281,6 +281,10 @@ public class FileUtils extends Plugin {
      * @throws JSONException
      */
     private JSONArray readEntries(String fileName) throws FileNotFoundException, JSONException
{
+        if (fileName.startsWith("file://")) {
+            fileName = fileName.substring(7);
+        }
+
         File fp = new File(fileName);
 
         if (!fp.exists()) {
@@ -314,7 +318,15 @@ public class FileUtils extends Plugin {
      * @throws EncodingException
      * @throws JSONException
      */
-    private JSONObject transferTo(String fileName, JSONObject newParent, String newName,
boolean move) throws JSONException, NoModificationAllowedException, IOException, InvalidModificationException,
EncodingException {
+    private JSONObject transferTo(String fileName, String newParent, String newName, boolean
move) throws JSONException, NoModificationAllowedException, IOException, InvalidModificationException,
EncodingException {
+        if (fileName.startsWith("file://")) {
+            fileName = fileName.substring(7);
+        }
+        if (newParent.startsWith("file://")) {
+            newParent = newParent.substring(7);
+        }
+
+
         // Check for invalid file name
         if (newName != null && newName.contains(":")) {
             throw new EncodingException("Bad file name");
@@ -327,7 +339,7 @@ public class FileUtils extends Plugin {
             throw new FileNotFoundException("The source does not exist");
         }
 
-        File destinationDir = new File(newParent.getString("fullPath"));
+        File destinationDir = new File(newParent);
         if (!destinationDir.exists()) {
             // The destination does not exist so we should fail.
             throw new FileNotFoundException("The source does not exist");


Mime
View raw message