cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhigg...@apache.org
Subject git commit: CB-5810 [BlackBerry10] resolve local:/// paths (application assets)
Date Fri, 17 Jan 2014 16:33:40 GMT
Updated Branches:
  refs/heads/dev 54a8e7de6 -> 3fe44cf5d


CB-5810 [BlackBerry10] resolve local:/// paths (application assets)


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

Branch: refs/heads/dev
Commit: 3fe44cf5df65a11638cca5f9da870a00bcc258bd
Parents: 54a8e7d
Author: Bryan Higgins <bhiggins@blackberry.com>
Authored: Thu Jan 16 16:00:25 2014 -0500
Committer: Bryan Higgins <bhiggins@blackberry.com>
Committed: Thu Jan 16 16:00:25 2014 -0500

----------------------------------------------------------------------
 src/blackberry10/index.js                     |  7 ++++++
 www/blackberry10/resolveLocalFileSystemURI.js | 29 ++++++++++++++++------
 2 files changed, 28 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/3fe44cf5/src/blackberry10/index.js
----------------------------------------------------------------------
diff --git a/src/blackberry10/index.js b/src/blackberry10/index.js
index 9e4cfd3..9c9c3e2 100644
--- a/src/blackberry10/index.js
+++ b/src/blackberry10/index.js
@@ -6,5 +6,12 @@ module.exports = {
 
     isSandboxed : function (success, fail, args, env) {
         new PluginResult(args, env).ok(require("lib/webview").getSandbox() === "1");
+    },
+
+    resolveLocalPath : function (success, fail, args, env) {
+        var homeDir = window.qnx.webplatform.getApplication().getEnv("HOME").replace("/data",
"/app/native/"),
+            path = homeDir + JSON.parse(decodeURIComponent(args[0])).substring(9);
+        require("lib/webview").setSandbox(false);
+        new PluginResult(args, env).ok(path);
     }
 };

http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/3fe44cf5/www/blackberry10/resolveLocalFileSystemURI.js
----------------------------------------------------------------------
diff --git a/www/blackberry10/resolveLocalFileSystemURI.js b/www/blackberry10/resolveLocalFileSystemURI.js
index fd0e217..a3f62f7 100644
--- a/www/blackberry10/resolveLocalFileSystemURI.js
+++ b/www/blackberry10/resolveLocalFileSystemURI.js
@@ -24,7 +24,7 @@ var fileUtils = require('./BB10Utils'),
 
 module.exports = function (uri, success, fail) {
 
-    var decodedURI = decodeURI(uri).replace(/filesystem:/, '').replace(/local:\/\//, '').replace(/file:\/\//,
''),
+    var decodedURI = decodeURI(uri).replace(/filesystem:/, '').replace(/file:\/\//, ''),
         failNotFound = function () {
             fail(FileError.NOT_FOUND_ERR);
         },
@@ -47,11 +47,24 @@ module.exports = function (uri, success, fail) {
             );
         };
 
-    cordova.exec(
-        resolveURI, 
-        failNotFound, 
-        'org.apache.cordova.file', 
-        'setSandbox', 
-        [!fileUtils.isOutsideSandbox(decodedURI)]
-    );
+    if (decodedURI.substring(0, 8) === 'local://') {
+        cordova.exec(
+            function (path) {
+                decodedURI = path;
+                resolveURI();
+            },
+            failNotFound,
+            'org.apache.cordova.file',
+            'resolveLocalPath',
+            [decodedURI]
+        );
+    } else {
+        cordova.exec(
+            resolveURI, 
+            failNotFound, 
+            'org.apache.cordova.file', 
+            'setSandbox', 
+            [!fileUtils.isOutsideSandbox(decodedURI)]
+        );
+    }
 };


Mime
View raw message