You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by fi...@apache.org on 2012/02/23 18:53:19 UTC

[23/35] git commit: copyTo and remove need failure wrappers

copyTo and remove need failure wrappers


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/commit/900fe464
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/tree/900fe464
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/diff/900fe464

Branch: refs/heads/ios
Commit: 900fe4647e27770826bded3e5a7aef26b469d0c1
Parents: 95485fc
Author: Fil Maj <fi...@nitobi.com>
Authored: Thu Feb 16 18:04:14 2012 -0800
Committer: Fil Maj <fi...@nitobi.com>
Committed: Thu Feb 16 18:04:14 2012 -0800

----------------------------------------------------------------------
 lib/plugin/Entry.js |   20 +++++++++++++-------
 1 files changed, 13 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/900fe464/lib/plugin/Entry.js
----------------------------------------------------------------------
diff --git a/lib/plugin/Entry.js b/lib/plugin/Entry.js
index 828feda..cd1b1f6 100644
--- a/lib/plugin/Entry.js
+++ b/lib/plugin/Entry.js
@@ -102,6 +102,12 @@ Entry.prototype.moveTo = function(parent, newName, successCallback, errorCallbac
  *            {Function} called with a FileError
  */
 Entry.prototype.copyTo = function(parent, newName, successCallback, errorCallback) {
+    // user must specify parent Entry
+    if (!parent) {
+        errorCallback(new FileError(FileError.NOT_FOUND_ERR));
+        return;
+    }
+
         // source path
     var srcPath = this.fullPath,
         // entry name
@@ -124,14 +130,11 @@ Entry.prototype.copyTo = function(parent, newName, successCallback, errorCallbac
                 // no Entry object returned
                 errorCallback(new FileError(FileError.NOT_FOUND_ERR));
             }
+        },
+        fail = function(code) {
+            errorCallback(new FileError(code));
         };
 
-    // user must specify parent Entry
-    if (!parent) {
-        errorCallback(new FileError(FileError.NOT_FOUND_ERR));
-        return;
-    }
-
     // copy
     exec(success, fail, "File", "copyTo", [srcPath, parent.fullPath, name]);
 };
@@ -161,7 +164,10 @@ Entry.prototype.toURL = function(mimeType, successCallback, errorCallback) {
  * @param errorCallback {Function} called with a FileError
  */
 Entry.prototype.remove = function(successCallback, errorCallback) {
-    exec(successCallback, errorCallback, "File", "remove", [this.fullPath]);
+    var fail = function(code) {
+      errorCallback(new FileError(code));
+    };
+    exec(successCallback, fail, "File", "remove", [this.fullPath]);
 };
 
 /**