cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhigg...@apache.org
Subject git commit: CB-4816 Fix file creation outside sandbox for BB10
Date Wed, 13 Nov 2013 13:44:50 GMT
Updated Branches:
  refs/heads/dev ca2c4e231 -> 43c901a2e


CB-4816 Fix file creation outside sandbox for BB10


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

Branch: refs/heads/dev
Commit: 43c901a2e67a58744177f7bcc2679a8b3072b578
Parents: ca2c4e2
Author: David Peacock <dapeacock@gmail.com>
Authored: Mon Nov 11 10:37:56 2013 -0500
Committer: Bryan Higgins <bhiggins@blackberry.com>
Committed: Wed Nov 13 08:44:56 2013 -0500

----------------------------------------------------------------------
 www/blackberry10/DirectoryEntry.js | 30 ++++++++++++++++++++++--------
 www/blackberry10/fileUtils.js      |  2 +-
 2 files changed, 23 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/43c901a2/www/blackberry10/DirectoryEntry.js
----------------------------------------------------------------------
diff --git a/www/blackberry10/DirectoryEntry.js b/www/blackberry10/DirectoryEntry.js
index cb6628d..f84395d 100644
--- a/www/blackberry10/DirectoryEntry.js
+++ b/www/blackberry10/DirectoryEntry.js
@@ -44,7 +44,14 @@ DirectoryEntry.prototype.createReader = function () {
 
 DirectoryEntry.prototype.getDirectory = function (path, options, successCallback, errorCallback)
{
     var sandboxState,
-        currentPath = this.nativeEntry.fullPath;
+        currentPath = this.nativeEntry.fullPath,
+        fullPath;
+
+    if (path.indexOf("/") === 0) {
+        fullPath = path;
+    } else {
+        fullPath = currentPath + "/" + path;
+    }
 
     cordova.exec(function (sandboxed) {
         sandboxState = sandboxed;
@@ -54,11 +61,11 @@ DirectoryEntry.prototype.getDirectory = function (path, options, successCallback
 
     argscheck.checkArgs('sOFF', 'DirectoryEntry.getDirectory', arguments);
 
-    if (fileUtils.isOutsideSandbox(path)) {
+    if (fileUtils.isOutsideSandbox(fullPath)) {
         cordova.exec(null, null, "org.apache.cordova.file", "setSandbox", [false]);
         window.webkitRequestFileSystem(window.PERSISTENT, this.filesystem._size, function
(fs) {
             cordova.exec(null, null, "org.apache.cordova.file", "setSandbox", [sandboxState]);
-            fs.root.getDirectory(currentPath + '/' + path, options, function (entry) {
+            fs.root.getDirectory(fullPath, options, function (entry) {
                 successCallback(fileUtils.createEntry(entry));
             }, err(sandboxState, errorCallback));
         }, err(sandboxState, errorCallback));
@@ -66,7 +73,7 @@ DirectoryEntry.prototype.getDirectory = function (path, options, successCallback
         cordova.exec(null, null, "org.apache.cordova.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.file", "setSandbox", [sandboxState]);
-            fs.root.getDirectory(currentPath + '/' + path, options, function (entry) {
+            fs.root.getDirectory(fullPath, options, function (entry) {
                 successCallback(fileUtils.createEntry(entry));
             }, err(sandboxState, errorCallback));
         }, err(sandboxState, errorCallback));
@@ -80,7 +87,14 @@ DirectoryEntry.prototype.removeRecursively = function (successCallback,
errorCal
 
 DirectoryEntry.prototype.getFile = function (path, options, successCallback, errorCallback)
{
     var sandboxState,
-        currentPath = this.nativeEntry.fullPath;
+        currentPath = this.nativeEntry.fullPath,
+        fullPath;
+
+    if (path.indexOf("/") === 0) {
+        fullPath = path;
+    } else {
+        fullPath = currentPath + "/" + path;
+    }
 
     cordova.exec(function (sandboxed) {
         sandboxState = sandboxed;
@@ -90,11 +104,11 @@ DirectoryEntry.prototype.getFile = function (path, options, successCallback,
err
 
     argscheck.checkArgs('sOFF', 'DirectoryEntry.getFile', arguments);
 
-    if (fileUtils.isOutsideSandbox(path)) {
+    if (fileUtils.isOutsideSandbox(fullPath)) {
         cordova.exec(null, null, "org.apache.cordova.file", "setSandbox", [false]);
         window.webkitRequestFileSystem(window.PERSISTENT, this.filesystem._size, function
(fs) {
             cordova.exec(null, null, "org.apache.cordova.file", "setSandbox", [sandboxState]);
-            fs.root.getFile(currentPath + '/' + path, options, function (entry) {
+            fs.root.getFile(fullPath, options, function (entry) {
                 successCallback(fileUtils.createEntry(entry));
             }, err(sandboxState, errorCallback));
         }, err(sandboxState, errorCallback));
@@ -102,7 +116,7 @@ DirectoryEntry.prototype.getFile = function (path, options, successCallback,
err
         cordova.exec(null, null, "org.apache.cordova.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.file", "setSandbox", [sandboxState]);
-            fs.root.getFile(currentPath + '/' + path, options, function (entry) {
+            fs.root.getFile(fullPath, options, function (entry) {
                 successCallback(fileUtils.createEntry(entry));
             }, err(sandboxState, errorCallback));
         }, err(sandboxState, errorCallback));

http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/43c901a2/www/blackberry10/fileUtils.js
----------------------------------------------------------------------
diff --git a/www/blackberry10/fileUtils.js b/www/blackberry10/fileUtils.js
index 6f803b7..06e676d 100644
--- a/www/blackberry10/fileUtils.js
+++ b/www/blackberry10/fileUtils.js
@@ -38,7 +38,7 @@ module.exports = {
     createFile: function (file) {
         var cordovaFile = new File(file.name, file.fullPath, file.type, file.lastModifiedDate,
file.size);
         cordovaFile.nativeFile = file;
-        cordovaFile.fullPath = file.name;
+        cordovaFile.fullPath = file.fullPath;
         return cordovaFile;
     },
 


Mime
View raw message