incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bcur...@apache.org
Subject [5/16] android commit: remove file:// protocol from various fileutils methods
Date Fri, 17 Feb 2012 22:58:02 GMT
remove file:// protocol from various fileutils  methods


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

Branch: refs/heads/master
Commit: cd667d6af5f1382747440ba5312ad740925758ec
Parents: 7e4158c
Author: Fil Maj <filip.maj@nitobi.com>
Authored: Thu Feb 16 17:46:16 2012 -0800
Committer: Fil Maj <filip.maj@nitobi.com>
Committed: Thu Feb 16 17:46:16 2012 -0800

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


http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/cd667d6a/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 87be54f..31a4f52 100755
--- a/framework/src/org/apache/cordova/FileUtils.java
+++ b/framework/src/org/apache/cordova/FileUtils.java
@@ -712,6 +712,10 @@ public class FileUtils extends Plugin {
      * @throws JSONException
      */
     private JSONObject getParent(String filePath) throws JSONException {
+        if (filePath.startsWith("file://")) {
+            filePath = filePath.substring(7);
+        }
+
         if (atRootDirectory(filePath)) {
             return getEntry(filePath);
         }
@@ -726,8 +730,13 @@ public class FileUtils extends Plugin {
      * @return true if we are at the root, false otherwise.
      */
     private boolean atRootDirectory(String filePath) {
+        if (filePath.startsWith("file://")) {
+            filePath = filePath.substring(7);
+        }
+
         if (filePath.equals(Environment.getExternalStorageDirectory().getAbsolutePath() +
"/Android/data/" + ctx.getPackageName() + "/cache") ||
-                filePath.equals(Environment.getExternalStorageDirectory().getAbsolutePath()))
{
+                filePath.equals(Environment.getExternalStorageDirectory().getAbsolutePath())
|| 
+                filePath.equals("/data/data/" + ctx.getPackageName() + "/")) {
             return true;
         }
         return false;
@@ -742,6 +751,10 @@ public class FileUtils extends Plugin {
      * @throws JSONException
      */
     private JSONObject getMetadata(String filePath) throws FileNotFoundException, JSONException
{
+        if (filePath.startsWith("file://")) {
+            filePath = filePath.substring(7);
+        }
+
         File file = new File(filePath);
 
         if (!file.exists()) {
@@ -766,6 +779,7 @@ public class FileUtils extends Plugin {
         if (filePath.startsWith("file://")) {
             filePath = filePath.substring(7);
         }
+
         File file = new File(filePath);
 
         if (!file.exists()) {
@@ -811,7 +825,7 @@ public class FileUtils extends Plugin {
         }
         else if (type == PERSISTENT) {
             fs.put("name", "persistent");
-            fs.put("root", "file:///data/data/" + ctx.getPackageName());
+            fs.put("root", "file:///data/data/" + ctx.getPackageName() + "/");
         }
         else {
             throw new IOException("No filesystem of type requested");


Mime
View raw message