You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by st...@apache.org on 2013/09/27 00:26:02 UTC

[02/14] git commit: [CB-2901] [BlackBerry10] Automatically unsandbox filesystem if path is not in app sandbox

[CB-2901] [BlackBerry10] Automatically unsandbox filesystem if path is not in app sandbox

Reviewed by Bryan Higgins <bh...@blackberry.com>
Tested by Tracy Li <tl...@blackberry.com>


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

Branch: refs/heads/master
Commit: 73a8604dd4e7ef7700adaef723babcdf550ecf34
Parents: 6a2565d
Author: Hasan Ahmad <ha...@blackberry.com>
Authored: Mon Jul 8 12:35:29 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri Sep 6 09:00:35 2013 -0400

----------------------------------------------------------------------
 plugin.xml                                    | 41 +++++++------
 src/blackberry10/index.js                     | 10 +++
 www/blackberry10/DirectoryEntry.js            | 71 +++++++++++++++++++---
 www/blackberry10/DirectoryReader.js           | 19 ++++--
 www/blackberry10/Entry.js                     | 12 +++-
 www/blackberry10/File.js                      | 54 ++++++++++++++++
 www/blackberry10/FileEntry.js                 | 10 +--
 www/blackberry10/FileReader.js                |  2 +-
 www/blackberry10/FileWriter.js                |  2 +-
 www/blackberry10/fileUtils.js                 | 19 +++---
 www/blackberry10/requestFileSystem.js         |  8 ++-
 www/blackberry10/resolveLocalFileSystemURI.js | 54 ++++++++--------
 12 files changed, 227 insertions(+), 75 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/73a8604d/plugin.xml
----------------------------------------------------------------------
diff --git a/plugin.xml b/plugin.xml
index d378c36..f08ca60 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -12,14 +12,14 @@ xmlns:android="http://schemas.android.com/apk/res/android"
     <js-module src="www/DirectoryEntry.js" name="DirectoryEntry">
         <clobbers target="window.DirectoryEntry" />
     </js-module>
-    
+
     <js-module src="www/DirectoryReader.js" name="DirectoryReader">
         <clobbers target="window.DirectoryReader" />
-    </js-module> 
-    
+    </js-module>
+
     <js-module src="www/Entry.js" name="Entry">
         <clobbers target="window.Entry" />
-    </js-module>       
+    </js-module>
 
     <js-module src="www/File.js" name="File">
         <clobbers target="window.File" />
@@ -40,11 +40,11 @@ xmlns:android="http://schemas.android.com/apk/res/android"
     <js-module src="www/FileSystem.js" name="FileSystem">
         <clobbers target="window.FileSystem" />
     </js-module>
-    
+
     <js-module src="www/FileUploadOptions.js" name="FileUploadOptions">
         <clobbers target="window.FileUploadOptions" />
     </js-module>
-    
+
     <js-module src="www/FileUploadResult.js" name="FileUploadResult">
         <clobbers target="window.FileUploadResult" />
     </js-module>
@@ -52,15 +52,15 @@ xmlns:android="http://schemas.android.com/apk/res/android"
     <js-module src="www/FileWriter.js" name="FileWriter">
         <clobbers target="window.FileWriter" />
     </js-module>
-    
+
     <js-module src="www/Flags.js" name="Flags">
         <clobbers target="window.Flags" />
-    </js-module>    
+    </js-module>
 
     <js-module src="www/LocalFileSystem.js" name="LocalFileSystem">
         <clobbers target="window.LocalFileSystem" />
     </js-module>
- 
+
     <js-module src="www/Metadata.js" name="Metadata">
         <clobbers target="window.Metadata" />
     </js-module>
@@ -72,11 +72,11 @@ xmlns:android="http://schemas.android.com/apk/res/android"
     <js-module src="www/requestFileSystem.js" name="requestFileSystem">
         <clobbers target="window.requestFileSystem" />
     </js-module>
-    
+
     <js-module src="www/resolveLocalFileSystemURI.js" name="resolveLocalFileSystemURI">
         <clobbers target="window.resolveLocalFileSystemURI" />
     </js-module>
-                                           
+
     <!-- android -->
     <platform name="android">
         <config-file target="res/xml/config.xml" parent="/*">
@@ -96,25 +96,25 @@ xmlns:android="http://schemas.android.com/apk/res/android"
         <source-file src="src/android/TypeMismatchException.java" target-dir="src/org/apache/cordova/file" />
         <source-file src="src/android/FileUtils.java" target-dir="src/org/apache/cordova/file" />
     </platform>
-    
+
     <!-- ios -->
-    <platform name="ios">    
+    <platform name="ios">
         <config-file target="config.xml" parent="/*">
             <feature name="File">
-                <param name="ios-package" value="CDVFile" /> 
+                <param name="ios-package" value="CDVFile" />
             </feature>
         </config-file>
         <header-file src="src/ios/CDVFile.h" />
         <source-file src="src/ios/CDVFile.m" />
-        
+
         <!-- ios specific file apis -->
         <js-module src="www/ios/Entry.js" name="Entry1">
             <merges target="window.Entry" />
         </js-module>
-        
+
         <framework src="AssetsLibrary.framework" />
         <framework src="MobileCoreServices.framework" />
-    </platform>    
+    </platform>
 
     <!-- wp7 -->
     <platform name="wp7">
@@ -164,7 +164,10 @@ xmlns:android="http://schemas.android.com/apk/res/android"
         </js-module>
         <js-module src="www/blackberry10/Entry.js" name="BB10Entry">
             <clobbers target="window.Entry" />
-        </js-module>       
+        </js-module>
+        <js-module src="www/blackberry10/File.js" name="BB10File">
+            <clobbers target="window.File" />
+        </js-module>
         <js-module src="www/blackberry10/FileEntry.js" name="BB10FileEntry">
             <clobbers target="window.FileEntry" />
         </js-module>
@@ -183,6 +186,8 @@ xmlns:android="http://schemas.android.com/apk/res/android"
         <js-module src="www/blackberry10/resolveLocalFileSystemURI.js" name="BB10resolveLocalFileSystemURI">
             <clobbers target="window.resolveLocalFileSystemURI" />
         </js-module>
+
+        <source-file src="src/blackberry10/index.js"></source-file>
     </platform>
 
     <!-- windows8 -->

http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/73a8604d/src/blackberry10/index.js
----------------------------------------------------------------------
diff --git a/src/blackberry10/index.js b/src/blackberry10/index.js
new file mode 100644
index 0000000..914d966
--- /dev/null
+++ b/src/blackberry10/index.js
@@ -0,0 +1,10 @@
+module.exports = {
+    setSandbox : function (success, fail, args, env) {
+        require("lib/webview").setSandbox(JSON.parse(decodeURIComponent(args[0])));
+        new PluginResult(args, env).noResult(false);
+    },
+
+    isSandboxed : function (success, fail, args, env) {
+        new PluginResult(args, env).ok(require("lib/webview").getSandbox() === "1");
+    }
+};

http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/73a8604d/www/blackberry10/DirectoryEntry.js
----------------------------------------------------------------------
diff --git a/www/blackberry10/DirectoryEntry.js b/www/blackberry10/DirectoryEntry.js
index 15289a7..295f88e 100644
--- a/www/blackberry10/DirectoryEntry.js
+++ b/www/blackberry10/DirectoryEntry.js
@@ -25,21 +25,52 @@ var argscheck = require('cordova/argscheck'),
     FileError = require('./FileError'),
     DirectoryReader = require('./BB10DirectoryReader'),
     fileUtils = require('./BB10Utils'),
-    DirectoryEntry = function (name, fullPath) {
-        DirectoryEntry.__super__.constructor.call(this, false, true, name, fullPath);
+    DirectoryEntry = function (name, fullPath, fileSystem) {
+        DirectoryEntry.__super__.constructor.call(this, false, true, name, fullPath, fileSystem);
     };
 
 utils.extend(DirectoryEntry, Entry);
 
+function err(sandboxState, errorCallback) {
+    return function (e) {
+        cordova.exec(null, null, "org.apache.cordova.core.file", "setSandbox", [sandboxState]);
+        errorCallback(e);
+    }
+};
+
 DirectoryEntry.prototype.createReader = function () {
     return new DirectoryReader(this.fullPath);
 };
 
 DirectoryEntry.prototype.getDirectory = function (path, options, successCallback, errorCallback) {
+    var sandboxState,
+        currentPath = this.nativeEntry.fullPath;
+
+    cordova.exec(function (sandboxed) {
+        sandboxState = sandboxed;
+    }, function (e) {
+        console.log("[ERROR]: Could not retrieve sandbox state ", e);
+    }, "org.apache.cordova.core.file", "isSandboxed");
+
     argscheck.checkArgs('sOFF', 'DirectoryEntry.getDirectory', arguments);
-    this.nativeEntry.getDirectory(path, options, function (entry) {
-        successCallback(fileUtils.createEntry(entry));
-    }, errorCallback);
+
+    if (fileUtils.isOutsideSandbox(path)) {
+        cordova.exec(null, null, "org.apache.cordova.core.file", "setSandbox", [false]);
+        window.webkitRequestFileSystem(window.PERSISTENT, this.filesystem._size, function (fs) {
+            cordova.exec(null, null, "org.apache.cordova.core.file", "setSandbox", [sandboxState]);
+            fs.root.getDirectory(currentPath + '/' + path, options, function (entry) {
+                successCallback(fileUtils.createEntry(entry));
+            }, err(sandboxState, errorCallback));
+        }, err(sandboxState, errorCallback));
+    } else {
+        cordova.exec(null, null, "org.apache.cordova.core.file", "setSandbox", [true]);
+        window.webkitRequestFileSystem(fileUtils.getFileSystemName(this.filesystem) === "persistent" ? window.PERSISTENT : window.TEMPORARY, this.filesystem._size, function (fs) {
+            cordova.exec(null, null, "org.apache.cordova.core.file", "setSandbox", [sandboxState]);
+            fs.root.getDirectory(currentPath + '/' + path, options, function (entry) {
+                successCallback(fileUtils.createEntry(entry));
+            }, err(sandboxState, errorCallback));
+        }, err(sandboxState, errorCallback));
+    }
 };
 
 DirectoryEntry.prototype.removeRecursively = function (successCallback, errorCallback) {
@@ -48,10 +79,34 @@ DirectoryEntry.prototype.removeRecursively = function (successCallback, errorCal
 };
 
 DirectoryEntry.prototype.getFile = function (path, options, successCallback, errorCallback) {
+    var sandboxState,
+        currentPath = this.nativeEntry.fullPath;
+
+    cordova.exec(function (sandboxed) {
+        sandboxState = sandboxed;
+    }, function (e) {
+        console.log("[ERROR]: Could not retrieve sandbox state ", e);
+    }, "org.apache.cordova.core.file", "isSandboxed");
+
     argscheck.checkArgs('sOFF', 'DirectoryEntry.getFile', arguments);
-    this.nativeEntry.getFile(path, options, function (entry) {
-        successCallback(fileUtils.createEntry(entry));
-    }, errorCallback);
+
+    if (fileUtils.isOutsideSandbox(path)) {
+        cordova.exec(null, null, "org.apache.cordova.core.file", "setSandbox", [false]);
+        window.webkitRequestFileSystem(window.PERSISTENT, this.filesystem._size, function (fs) {
+            cordova.exec(null, null, "org.apache.cordova.core.file", "setSandbox", [sandboxState]);
+            fs.root.getFile(currentPath + '/' + path, options, function (entry) {
+                successCallback(fileUtils.createEntry(entry));
+            }, err(sandboxState, errorCallback));
+        }, err(sandboxState, errorCallback));
+    } else {
+        cordova.exec(null, null, "org.apache.cordova.core.file", "setSandbox", [true]);
+        window.webkitRequestFileSystem(fileUtils.getFileSystemName(this.filesystem) === "persistent" ? window.PERSISTENT: window.TEMPORARY, this.filesystem._size, function (fs) {
+            cordova.exec(null, null, "org.apache.cordova.core.file", "setSandbox", [sandboxState]);
+            fs.root.getFile(currentPath + '/' + path, options, function (entry) {
+                successCallback(fileUtils.createEntry(entry));
+            }, err(sandboxState, errorCallback));
+        }, err(sandboxState, errorCallback));
+    }
 };
 
 module.exports = DirectoryEntry;

http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/73a8604d/www/blackberry10/DirectoryReader.js
----------------------------------------------------------------------
diff --git a/www/blackberry10/DirectoryReader.js b/www/blackberry10/DirectoryReader.js
index a188545..6aa3d73 100644
--- a/www/blackberry10/DirectoryReader.js
+++ b/www/blackberry10/DirectoryReader.js
@@ -24,10 +24,12 @@ var FileError = require('./FileError'),
 
 function DirectoryReader(path) {
     this.path = path;
+    this.nativeReader = null;
 }
 
 DirectoryReader.prototype.readEntries = function(successCallback, errorCallback) {
-    var win = typeof successCallback !== 'function' ? null : function(result) {
+    var self = this,
+        win = typeof successCallback !== 'function' ? null : function(result) {
             var retVal = [];
             for (var i=0; i<result.length; i++) {
                 retVal.push(fileUtils.createEntry(result[i]));
@@ -37,11 +39,16 @@ DirectoryReader.prototype.readEntries = function(successCallback, errorCallback)
         fail = typeof errorCallback !== 'function' ? null : function(code) {
             errorCallback(new FileError(code));
         };
-    fileUtils.getEntryForURI(this.path, function (entry) {
-        entry.nativeEntry.createReader().readEntries(win, fail);
-    }, function () {
-        fail(FileError.NOT_FOUND_ERR);
-    });
+    if (this.nativeReader) {
+        this.nativeReader.readEntries(win, fail);
+    } else {
+        resolveLocalFileSystemURI("filesystem:local:///persistent/" + this.path, function (entry) {
+            self.nativeReader = entry.nativeEntry.createReader()
+            self.nativeReader.readEntries(win, fail);
+        }, function () {
+            fail(FileError.NOT_FOUND_ERR);
+        });
+    }
 };
 
 module.exports = DirectoryReader;

http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/73a8604d/www/blackberry10/Entry.js
----------------------------------------------------------------------
diff --git a/www/blackberry10/Entry.js b/www/blackberry10/Entry.js
index 6bad13c..d432bfd 100644
--- a/www/blackberry10/Entry.js
+++ b/www/blackberry10/Entry.js
@@ -25,10 +25,14 @@ var argscheck = require('cordova/argscheck'),
     fileUtils = require('./BB10Utils');
 
 function Entry(isFile, isDirectory, name, fullPath, fileSystem) {
+    var strippedPath;
+    if (fullPath && fullPath.charAt(fullPath.length - 1) === '/') {
+        strippedPath = fullPath.slice(0, -1);
+    }
     this.isFile = !!isFile;
     this.isDirectory = !!isDirectory;
     this.name = name || '';
-    this.fullPath = fullPath || '';
+    this.fullPath = typeof strippedPath !== "undefined" ? strippedPath : (fullPath || '');
     this.filesystem = fileSystem || null;
 }
 
@@ -88,7 +92,11 @@ Entry.prototype.copyTo = function(parent, newName, successCallback, errorCallbac
 };
 
 Entry.prototype.toURL = function() {
-    return this.fullPath;
+    var nativeURI = this.nativeEntry.toURL();
+    if (nativeURI.charAt(nativeURI.length - 1) === '/') {
+        return nativeURI.slice(0, -1);
+    }
+    return nativeURI;
 };
 
 Entry.prototype.toURI = function(mimeType) {

http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/73a8604d/www/blackberry10/File.js
----------------------------------------------------------------------
diff --git a/www/blackberry10/File.js b/www/blackberry10/File.js
new file mode 100644
index 0000000..0ed39fd
--- /dev/null
+++ b/www/blackberry10/File.js
@@ -0,0 +1,54 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+
+/**
+ * Constructor.
+ * name {DOMString} name of the file, without path information
+ * fullPath {DOMString} the full path of the file, including the name
+ * type {DOMString} mime type
+ * lastModifiedDate {Date} last modified date
+ * size {Number} size of the file in bytes
+ */
+
+var File = function(name, fullPath, type, lastModifiedDate, size){
+    this.name = name || '';
+    this.fullPath = fullPath || null;
+    this.type = type || null;
+    this.lastModifiedDate = lastModifiedDate || null;
+    this.size = size || 0;
+
+    // These store the absolute start and end for slicing the file.
+    this.start = 0;
+    this.end = this.size;
+};
+
+/**
+ * Returns a "slice" of the file.
+ * Slices of slices are supported.
+ * start {Number} The index at which to start the slice (inclusive).
+ * end {Number} The index at which to end the slice (exclusive).
+ */
+File.prototype.slice = function(start, end) {
+    return fileUtils.createFile(this.nativeFile.slice(start, end));
+};
+
+
+module.exports = File;

http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/73a8604d/www/blackberry10/FileEntry.js
----------------------------------------------------------------------
diff --git a/www/blackberry10/FileEntry.js b/www/blackberry10/FileEntry.js
index 55927cd..b358d71 100644
--- a/www/blackberry10/FileEntry.js
+++ b/www/blackberry10/FileEntry.js
@@ -22,10 +22,11 @@
 var utils = require('cordova/utils'),
     Entry = require('./BB10Entry'),
     FileWriter = require('./BB10FileWriter'),
-    File = require('./File'),
+    File = require('./BB10File'),
+    fileUtils = require('./BB10Utils'),
     FileError = require('./FileError'),
-    FileEntry = function (name, fullPath) {
-        FileEntry.__super__.constructor.apply(this, [true, false, name, fullPath]);
+    FileEntry = function (name, fullPath, fileSystem) {
+        FileEntry.__super__.constructor.apply(this, [true, false, name, fullPath, fileSystem]);
     };
 
 utils.extend(FileEntry, Entry);
@@ -39,7 +40,8 @@ FileEntry.prototype.createWriter = function(successCallback, errorCallback) {
 FileEntry.prototype.file = function(successCallback, errorCallback) {
     var fullPath = this.fullPath,
         success = function (file) {
-            successCallback(new File(file.name, fullPath, file.type, file.lastModifiedDate, file.size));
+            file.fullPath = fullPath;
+            successCallback(fileUtils.createFile(file));
         };
     this.nativeEntry.file(success, errorCallback);
 };

http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/73a8604d/www/blackberry10/FileReader.js
----------------------------------------------------------------------
diff --git a/www/blackberry10/FileReader.js b/www/blackberry10/FileReader.js
index 8210137..6e3a10c 100644
--- a/www/blackberry10/FileReader.js
+++ b/www/blackberry10/FileReader.js
@@ -60,7 +60,7 @@ FileReader.prototype.abort = function() {
 
 function read(method, context, file, encoding) {
     if (file.fullPath) {
-         fileUtils.getEntryForURI(file.fullPath, function (entry) {
+         resolveLocalFileSystemURI("filesystem:local:///persistent/" + file.fullPath, function (entry) {
             entry.nativeEntry.file(function (nativeFile) {
                 context.nativeReader[method].call(context.nativeReader, nativeFile, encoding);
             }, context.onerror);

http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/73a8604d/www/blackberry10/FileWriter.js
----------------------------------------------------------------------
diff --git a/www/blackberry10/FileWriter.js b/www/blackberry10/FileWriter.js
index 4c7521d..8992943 100644
--- a/www/blackberry10/FileWriter.js
+++ b/www/blackberry10/FileWriter.js
@@ -29,7 +29,7 @@ function FileWriter (file) {
     this.file = file;
     this.events = {};
     this.pending = [];
-    fileUtils.getEntryForURI(file.fullPath, function (entry) {
+    resolveLocalFileSystemURI("filesystem:local:///persistent/" + file.fullPath, function (entry) {
         entry.nativeEntry.createWriter(function (writer) {
             var i,
                 event;

http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/73a8604d/www/blackberry10/fileUtils.js
----------------------------------------------------------------------
diff --git a/www/blackberry10/fileUtils.js b/www/blackberry10/fileUtils.js
index e26e4e9..6f803b7 100644
--- a/www/blackberry10/fileUtils.js
+++ b/www/blackberry10/fileUtils.js
@@ -24,24 +24,29 @@ function convertPath(url) {
 }
 
 module.exports = {
-
     createEntry: function (entry) {
         var cordovaEntry;
         if (entry.isFile) {
-            cordovaEntry = new window.FileEntry(entry.name, convertPath(entry.toURL()));
+            cordovaEntry = new window.FileEntry(entry.name, entry.fullPath, entry.filesystem);
         } else {
-            cordovaEntry = new window.DirectoryEntry(entry.name, convertPath(entry.toURL()));
+            cordovaEntry = new window.DirectoryEntry(entry.name, entry.fullPath, entry.filesystem);
         }
         cordovaEntry.nativeEntry = entry;
         return cordovaEntry;
     },
 
-    getEntryForURI: function (uri, success, fail) {
-        //TODO: account for local vs file system
-        window.resolveLocalFileSystemURI(uri, success, fail);
+    createFile: function (file) {
+        var cordovaFile = new File(file.name, file.fullPath, file.type, file.lastModifiedDate, file.size);
+        cordovaFile.nativeFile = file;
+        cordovaFile.fullPath = file.name;
+        return cordovaFile;
     },
 
     getFileSystemName: function (fs) {
-        return (fs.name.indexOf('Persistent') != -1) ? 'persistent' : 'temporary';
+        return ((fs.name.indexOf('Persistent') != -1) || (fs.name === "persistent")) ? 'persistent' : 'temporary';
+    },
+
+    isOutsideSandbox: function (path) {
+        return (path.indexOf("accounts/1000/") === 0 || path.indexOf("/accounts/1000/") === 0);
     }
 };

http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/73a8604d/www/blackberry10/requestFileSystem.js
----------------------------------------------------------------------
diff --git a/www/blackberry10/requestFileSystem.js b/www/blackberry10/requestFileSystem.js
index bb97564..bd07d08 100644
--- a/www/blackberry10/requestFileSystem.js
+++ b/www/blackberry10/requestFileSystem.js
@@ -24,13 +24,19 @@ var fileUtils = require('./BB10Utils'),
     FileSystem = require('./BB10FileSystem');
 
 module.exports = function (type, size, success, fail) {
+    var cordovaFs,
+        cordovaFsRoot;
     if (size >= 1000000000000000) {
         fail(new FileError(FileError.QUOTA_EXCEEDED_ERR));
     } else if (type !== 1 && type !== 0) {
         fail(new FileError(FileError.SYNTAX_ERR));
     } else {
         window.webkitRequestFileSystem(type, size, function (fs) {
-            success((new FileSystem(fileUtils.getFileSystemName(fs), fileUtils.createEntry(fs.root))));
+            cordovaFsRoot = fileUtils.createEntry(fs.root);
+            cordovaFs = new FileSystem(fileUtils.getFileSystemName(fs), cordovaFsRoot);
+            cordovaFsRoot.filesystem = cordovaFs;
+            cordovaFs._size = size;
+            success(cordovaFs);
         }, function (error) {
             fail(new FileError(error));
         });

http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/73a8604d/www/blackberry10/resolveLocalFileSystemURI.js
----------------------------------------------------------------------
diff --git a/www/blackberry10/resolveLocalFileSystemURI.js b/www/blackberry10/resolveLocalFileSystemURI.js
index 02e9e6c..06c1f73 100644
--- a/www/blackberry10/resolveLocalFileSystemURI.js
+++ b/www/blackberry10/resolveLocalFileSystemURI.js
@@ -22,34 +22,34 @@
 var fileUtils = require('./BB10Utils'),
     FileError = require('./FileError');
 
+function stripURI(uri) {
+    var rmFsLocal = uri.substring("filesystem:local:///".length);
+    return rmFsLocal.substring(rmFsLocal.indexOf('/') + 1);
+}
+
 module.exports = function (uri, success, fail) {
-    var type,
-        path,
-        paramPath;
-    if (!uri || uri.indexOf("/") === 0) {
-        fail(new FileError(FileError.ENCODING_ERR));
+    var sandboxState,
+        decodedURI = decodeURI(uri);
+
+    cordova.exec(function (sandboxed) {
+        sandboxState = sandboxed;
+    }, function (e) {
+        console.log("[ERROR]: Could not retrieve sandbox state ", e);
+    }, "org.apache.cordova.core.file", "isSandboxed");
+
+    if (fileUtils.isOutsideSandbox(stripURI(decodedURI))) {
+        cordova.exec(null, null, "org.apache.cordova.core.file", "setSandbox", [false]);
     } else {
-        type = uri.indexOf("persistent") === -1 ? 0 : 1;
-        path = uri.substring(type === 1 ? uri.indexOf("persistent") + 11 : uri.indexOf("temporary") + 10);
-        if (path.substring(0,1) == "/") {
-            path = path.substring(1);
-        }
-        paramPath = path.indexOf("?");
-        if (paramPath > -1) {
-            path = path.substring(0, paramPath);
-        }
-        window.webkitRequestFileSystem(type, 25*1024*1024, function (fs) {
-            if (path === "") {
-                success(fileUtils.createEntry(fs.root));
-            } else {
-                fs.root.getDirectory(path, {}, function (entry) {
-                    success(fileUtils.createEntry(entry));
-                }, function () {
-                    fs.root.getFile(path, {}, function (entry) {
-                        success(fileUtils.createEntry(entry));
-                    }, fail);
-                });
-            }
-        }, fail);
+        cordova.exec(null, null, "org.apache.cordova.core.file", "setSandbox", [true]);
     }
+    window.webkitResolveLocalFileSystemURL(decodedURI, function (entry) {
+        success(fileUtils.createEntry(entry));
+    }, function (e) {
+        window.webkitResolveLocalFileSystemURL(decodedURI + '/', function (entry) {
+            success(fileUtils.createEntry(entry));
+        }, function (e) {
+            fail(e);
+        });
+    });
+    cordova.exec(null, null, "org.apache.cordova.core.file", "setSandbox", [sandboxState]);
 };