Return-Path: X-Original-To: apmail-cordova-commits-archive@www.apache.org Delivered-To: apmail-cordova-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B51AE10ABC for ; Mon, 10 Feb 2014 23:26:37 +0000 (UTC) Received: (qmail 79104 invoked by uid 500); 10 Feb 2014 23:23:15 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 78082 invoked by uid 500); 10 Feb 2014 23:22:43 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cordova.apache.org Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 77504 invoked by uid 99); 10 Feb 2014 23:22:28 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 10 Feb 2014 23:22:28 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 235FF922DCB; Mon, 10 Feb 2014 23:22:28 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: steven@apache.org To: commits@cordova.apache.org Date: Mon, 10 Feb 2014 23:22:38 -0000 Message-Id: <3913fe4d6cb74e84bcff5acfe65aa614@git.apache.org> In-Reply-To: <4f6ca4f3c16b4269bc790ad4ed976363@git.apache.org> References: <4f6ca4f3c16b4269bc790ad4ed976363@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [12/50] git commit: CB-5699 [BlackBerry10] Update resolveLocalFileSystemURI implementation CB-5699 [BlackBerry10] Update resolveLocalFileSystemURI implementation The native webkitResolveLocalFileSystemURI does not support accessing URIs outside of the application sandbox. 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/b7882772 Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/tree/b7882772 Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/diff/b7882772 Branch: refs/heads/master Commit: b7882772b329c0690e0eaef264a21661c3e2f659 Parents: a76de41 Author: Bryan Higgins Authored: Tue Dec 24 10:59:12 2013 -0500 Committer: Bryan Higgins Committed: Tue Dec 24 11:43:58 2013 -0500 ---------------------------------------------------------------------- src/blackberry10/index.js | 2 +- www/blackberry10/fileUtils.js | 2 +- www/blackberry10/resolveLocalFileSystemURI.js | 58 +++++++++++----------- 3 files changed, 31 insertions(+), 31 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/b7882772/src/blackberry10/index.js ---------------------------------------------------------------------- diff --git a/src/blackberry10/index.js b/src/blackberry10/index.js index 914d966..9e4cfd3 100644 --- a/src/blackberry10/index.js +++ b/src/blackberry10/index.js @@ -1,7 +1,7 @@ module.exports = { setSandbox : function (success, fail, args, env) { require("lib/webview").setSandbox(JSON.parse(decodeURIComponent(args[0]))); - new PluginResult(args, env).noResult(false); + new PluginResult(args, env).ok(); }, isSandboxed : function (success, fail, args, env) { http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/b7882772/www/blackberry10/fileUtils.js ---------------------------------------------------------------------- diff --git a/www/blackberry10/fileUtils.js b/www/blackberry10/fileUtils.js index 06e676d..740669c 100644 --- a/www/blackberry10/fileUtils.js +++ b/www/blackberry10/fileUtils.js @@ -47,6 +47,6 @@ module.exports = { }, isOutsideSandbox: function (path) { - return (path.indexOf("accounts/1000/") === 0 || path.indexOf("/accounts/1000/") === 0); + return (path.indexOf("accounts/1000") !== -1); } }; http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/b7882772/www/blackberry10/resolveLocalFileSystemURI.js ---------------------------------------------------------------------- diff --git a/www/blackberry10/resolveLocalFileSystemURI.js b/www/blackberry10/resolveLocalFileSystemURI.js index 3ede22c..f447a42 100644 --- a/www/blackberry10/resolveLocalFileSystemURI.js +++ b/www/blackberry10/resolveLocalFileSystemURI.js @@ -22,36 +22,36 @@ 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 sandboxState, - decodedURI = decodeURI(uri); - cordova.exec(function (sandboxed) { - sandboxState = sandboxed; - }, function (e) { - console.log("[ERROR]: Could not retrieve sandbox state ", e); - }, "org.apache.cordova.file", "isSandboxed"); + var decodedURI = decodeURI(uri).replace(/filesystem:/, '').replace(/local:\/\//, '').replace(/file:\/\//, ''), + failNotFound = function () { + fail(FileError.NOT_FOUND_ERR); + }, + resolveURI = function () { + window.webkitRequestFileSystem( + window.PERSISTENT, + //todo: match app quota (this is only used for sandboxed fs) + 50*1024*1024, + function (fs) { + fs.root.getFile( + decodedURI, + { create: false }, + function (entry) { + success(fileUtils.createEntry(entry)); + }, + failNotFound + ); + }, + failNotFound + ); + }; - if (fileUtils.isOutsideSandbox(stripURI(decodedURI))) { - cordova.exec(null, null, "org.apache.cordova.file", "setSandbox", [false]); - } else { - cordova.exec(null, null, "org.apache.cordova.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) { - if (typeof fail === "function") { - fail(e); - } - }); - }); - cordova.exec(null, null, "org.apache.cordova.file", "setSandbox", [sandboxState]); + cordova.exec( + resolveURI, + failNotFound, + 'org.apache.cordova.file', + 'setSandbox', + [!fileUtils.isOutsideSandbox(decodedURI)] + ); };