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 BF46210E97 for ; Fri, 28 Feb 2014 21:37:05 +0000 (UTC) Received: (qmail 18915 invoked by uid 500); 28 Feb 2014 21:35:49 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 18764 invoked by uid 500); 28 Feb 2014 21:35:47 -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 18449 invoked by uid 99); 28 Feb 2014 21:35:40 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 28 Feb 2014 21:35:40 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id BFDFF9317CE; Fri, 28 Feb 2014 21:35:38 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: agrieve@apache.org To: commits@cordova.apache.org Date: Fri, 28 Feb 2014 21:36:03 -0000 Message-Id: <58a70b9a19d246239157ba481f8a3c70@git.apache.org> In-Reply-To: <3b79d91e66fb4b568a5795616873908b@git.apache.org> References: <3b79d91e66fb4b568a5795616873908b@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [26/40] git commit: Port lmnbeyond's File fixes to Android as well Port lmnbeyond's File fixes to Android as well 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/8b0ada7f Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/tree/8b0ada7f Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/diff/8b0ada7f Branch: refs/heads/master Commit: 8b0ada7fc3bc19f17c7cc47042f8a55996fa4a2e Parents: d28a671 Author: Ian Clelland Authored: Tue Feb 25 10:22:47 2014 -0500 Committer: Ian Clelland Committed: Tue Feb 25 10:28:16 2014 -0500 ---------------------------------------------------------------------- src/android/FileUtils.java | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/8b0ada7f/src/android/FileUtils.java ---------------------------------------------------------------------- diff --git a/src/android/FileUtils.java b/src/android/FileUtils.java index ac29f0d..caaf573 100644 --- a/src/android/FileUtils.java +++ b/src/android/FileUtils.java @@ -445,16 +445,26 @@ public class FileUtils extends CordovaPlugin { } public LocalFilesystemURL filesystemURLforLocalPath(String localPath) { - LocalFilesystemURL localURL; - for (Filesystem fs: filesystems) { - if (fs != null) { - localURL = fs.URLforFilesystemPath(localPath); - if (localURL != null) - return localURL; - } - } - return null; - } + LocalFilesystemURL localURL = null; + int shortestFullPath = 0; + + // Try all installed filesystems. Return the best matching URL + // (determined by the shortest resulting URL) + for (Filesystem fs: filesystems) { + if (fs != null) { + LocalFilesystemURL url = fs.URLforFilesystemPath(localPath); + if (url != null) { + // A shorter fullPath implies that the filesystem is a better + // match for the local path than the previous best. + if (localURL == null || (url.fullPath.length() < shortestFullPath)) { + localURL = url; + shortestFullPath = url.fullPath.length(); + } + } + } + } + return localURL; + } /* helper to execute functions async and handle the result codes