Return-Path: X-Original-To: apmail-incubator-callback-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-callback-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E149D9F9D for ; Fri, 17 Feb 2012 22:58:23 +0000 (UTC) Received: (qmail 10450 invoked by uid 500); 17 Feb 2012 22:58:23 -0000 Delivered-To: apmail-incubator-callback-commits-archive@incubator.apache.org Received: (qmail 10410 invoked by uid 500); 17 Feb 2012 22:58:23 -0000 Mailing-List: contact callback-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: callback-dev@incubator.apache.org Delivered-To: mailing list callback-commits@incubator.apache.org Received: (qmail 10400 invoked by uid 99); 17 Feb 2012 22:58:23 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 17 Feb 2012 22:58:23 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.114] (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 17 Feb 2012 22:58:22 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 542A3320907; Fri, 17 Feb 2012 22:58:02 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: bcurtis@apache.org To: callback-commits@incubator.apache.org X-Mailer: ASF-Git Admin Mailer Subject: [3/16] android commit: Use strings not objects Message-Id: <20120217225802.542A3320907@tyr.zones.apache.org> Date: Fri, 17 Feb 2012 22:58:02 +0000 (UTC) Use strings not objects Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/commit/d87ee719 Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/tree/d87ee719 Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/diff/d87ee719 Branch: refs/heads/master Commit: d87ee719a301e8603518b75cb3a3c17666d18f63 Parents: a52ba37 Author: Fil Maj Authored: Thu Feb 16 18:17:25 2012 -0800 Committer: Fil Maj Committed: Thu Feb 16 18:17:25 2012 -0800 ---------------------------------------------------------------------- framework/src/org/apache/cordova/FileUtils.java | 20 ++++++++++++++--- 1 files changed, 16 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/d87ee719/framework/src/org/apache/cordova/FileUtils.java ---------------------------------------------------------------------- diff --git a/framework/src/org/apache/cordova/FileUtils.java b/framework/src/org/apache/cordova/FileUtils.java index 73a1486..c148967 100755 --- a/framework/src/org/apache/cordova/FileUtils.java +++ b/framework/src/org/apache/cordova/FileUtils.java @@ -185,11 +185,11 @@ public class FileUtils extends Plugin { } } else if (action.equals("moveTo")) { - JSONObject entry = transferTo(args.getString(0), args.getJSONObject(1), args.optString(2), true); + JSONObject entry = transferTo(args.getString(0), args.getString(1), args.getString(2), true); return new PluginResult(status, entry); } else if (action.equals("copyTo")) { - JSONObject entry = transferTo(args.getString(0), args.getJSONObject(1), args.optString(2), false); + JSONObject entry = transferTo(args.getString(0), args.getString(1), args.getString(2), false); return new PluginResult(status, entry); } else if (action.equals("readEntries")) { @@ -281,6 +281,10 @@ public class FileUtils extends Plugin { * @throws JSONException */ private JSONArray readEntries(String fileName) throws FileNotFoundException, JSONException { + if (fileName.startsWith("file://")) { + fileName = fileName.substring(7); + } + File fp = new File(fileName); if (!fp.exists()) { @@ -314,7 +318,15 @@ public class FileUtils extends Plugin { * @throws EncodingException * @throws JSONException */ - private JSONObject transferTo(String fileName, JSONObject newParent, String newName, boolean move) throws JSONException, NoModificationAllowedException, IOException, InvalidModificationException, EncodingException { + private JSONObject transferTo(String fileName, String newParent, String newName, boolean move) throws JSONException, NoModificationAllowedException, IOException, InvalidModificationException, EncodingException { + if (fileName.startsWith("file://")) { + fileName = fileName.substring(7); + } + if (newParent.startsWith("file://")) { + newParent = newParent.substring(7); + } + + // Check for invalid file name if (newName != null && newName.contains(":")) { throw new EncodingException("Bad file name"); @@ -327,7 +339,7 @@ public class FileUtils extends Plugin { throw new FileNotFoundException("The source does not exist"); } - File destinationDir = new File(newParent.getString("fullPath")); + File destinationDir = new File(newParent); if (!destinationDir.exists()) { // The destination does not exist so we should fail. throw new FileNotFoundException("The source does not exist");