You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ti...@apache.org on 2013/03/21 23:02:36 UTC

[1/2] webworks commit: [CB-2646] added fileSize method to file utilities

Updated Branches:
  refs/heads/master 1e9e95ad5 -> e50fcd5ad


[CB-2646] added fileSize method to file utilities


Project: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/commit/3dba2eda
Tree: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/tree/3dba2eda
Diff: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/diff/3dba2eda

Branch: refs/heads/master
Commit: 3dba2edaa9a34d70f1110c27d8c54c2c7fe2925c
Parents: 1e9e95a
Author: lorinbeer <lo...@adobe.com>
Authored: Thu Mar 21 14:23:06 2013 -0700
Committer: lorinbeer <lo...@adobe.com>
Committed: Thu Mar 21 14:23:06 2013 -0700

----------------------------------------------------------------------
 .../ext/src/org/apache/cordova/util/FileUtils.java |   22 ++++++++++++++-
 1 files changed, 21 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/3dba2eda/framework/ext/src/org/apache/cordova/util/FileUtils.java
----------------------------------------------------------------------
diff --git a/framework/ext/src/org/apache/cordova/util/FileUtils.java b/framework/ext/src/org/apache/cordova/util/FileUtils.java
index 622bf48..6ca1ffe 100644
--- a/framework/ext/src/org/apache/cordova/util/FileUtils.java
+++ b/framework/ext/src/org/apache/cordova/util/FileUtils.java
@@ -228,7 +228,7 @@ public class FileUtils {
     public static void mkdir(String dirPath) throws IOException {
         FileConnection fconn = null;
         try {
-            fconn = (FileConnection)Connector.open(dirPath);
+            fconn = (FileConnection)Connector.open(dirPath, Connector.READ);
             if (fconn.isDirectory()) {
                 // nothing to do
                 return;
@@ -248,6 +248,26 @@ public class FileUtils {
     }
 
     /**
+     * Determines the size of a file on the file system. Size always represents number of bytes contained in the file; never pre-allocated but empty space
+     * @return size in bytes of the selected file, or -1 if the file does not exist or is inaccessible
+     */
+    public static long fileSize(String path) throws IOException {
+        FileConnection fconn = null;
+        long fsize = -1;
+        try {
+            fconn = (FileConnection)Connector.open(path);
+            fsize = fconn.fileSize();
+        } catch (IOException e) {
+            Logger.log(FileUtils.class.getName() + " fileSize:  " + path + "not found or inaccessible");
+        } finally {
+            try {
+                if (fconn != null) fconn.close();
+            } catch (IOException ignored) {}
+        }
+       return fsize;
+    }
+
+    /**
      * Copies a file or directory to a new location. If copying a directory, the
      * entire contents of the directory are copied recursively.
      *


[2/2] webworks commit: [CB-2646] removed mistaken modification to mkdir file access

Posted by ti...@apache.org.
[CB-2646] removed mistaken modification to mkdir file access


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

Branch: refs/heads/master
Commit: e50fcd5add827d28db02f401c7b14cdf2046f815
Parents: 3dba2ed
Author: lorinbeer <lo...@adobe.com>
Authored: Thu Mar 21 14:27:22 2013 -0700
Committer: lorinbeer <lo...@adobe.com>
Committed: Thu Mar 21 14:27:22 2013 -0700

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


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/e50fcd5a/framework/ext/src/org/apache/cordova/util/FileUtils.java
----------------------------------------------------------------------
diff --git a/framework/ext/src/org/apache/cordova/util/FileUtils.java b/framework/ext/src/org/apache/cordova/util/FileUtils.java
index 6ca1ffe..20ef492 100644
--- a/framework/ext/src/org/apache/cordova/util/FileUtils.java
+++ b/framework/ext/src/org/apache/cordova/util/FileUtils.java
@@ -228,7 +228,7 @@ public class FileUtils {
     public static void mkdir(String dirPath) throws IOException {
         FileConnection fconn = null;
         try {
-            fconn = (FileConnection)Connector.open(dirPath, Connector.READ);
+            fconn = (FileConnection)Connector.open(dirPath);
             if (fconn.isDirectory()) {
                 // nothing to do
                 return;