incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bcur...@apache.org
Subject [2/16] android commit: trim file:// URI from uri->path conversion method
Date Fri, 17 Feb 2012 22:58:02 GMT
trim file:// URI from uri->path conversion method


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

Branch: refs/heads/master
Commit: 7c1eb7da9b1d00aec92ffd153b5d561f4abde266
Parents: d87ee71
Author: Fil Maj <filip.maj@nitobi.com>
Authored: Fri Feb 17 10:55:04 2012 -0800
Committer: Fil Maj <filip.maj@nitobi.com>
Committed: Fri Feb 17 10:55:04 2012 -0800

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


http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/7c1eb7da/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 c148967..51fc4ab 100755
--- a/framework/src/org/apache/cordova/FileUtils.java
+++ b/framework/src/org/apache/cordova/FileUtils.java
@@ -914,8 +914,8 @@ public class FileUtils extends Plugin {
      */
     public String readAsText(String filename, String encoding) throws FileNotFoundException,
IOException {
         byte[] bytes = new byte[1000];
-           BufferedInputStream bis = new BufferedInputStream(getPathFromUri(filename), 1024);
-           ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        BufferedInputStream bis = new BufferedInputStream(getPathFromUri(filename), 1024);
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
         int numRead = 0;
         while ((numRead = bis.read(bytes, 0, 1000)) >= 0) {
             bos.write(bytes, 0, numRead);
@@ -1025,6 +1025,9 @@ public class FileUtils extends Plugin {
             return ctx.getContentResolver().openInputStream(uri);
         }
         else {
+            if (path.startsWith("file://")) {
+                path = path.substring(7);
+            }
             return new FileInputStream(path);
         }
     }


Mime
View raw message