You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ti...@apache.org on 2012/06/07 22:40:44 UTC

[16/48] js commit: cleaning code up

cleaning code up


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/62c51ff4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/tree/62c51ff4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/diff/62c51ff4

Branch: refs/heads/master
Commit: 62c51ff4b95cd4297942a68bb2ef66504528ed28
Parents: 97dc874
Author: Tim Kim <ti...@nitobi.com>
Authored: Wed May 30 18:55:36 2012 -0700
Committer: Tim Kim <ti...@nitobi.com>
Committed: Thu Jun 7 13:40:24 2012 -0700

----------------------------------------------------------------------
 lib/playbook/plugin/playbook/Entry.js |   68 +++++++++++----------------
 1 files changed, 28 insertions(+), 40 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/62c51ff4/lib/playbook/plugin/playbook/Entry.js
----------------------------------------------------------------------
diff --git a/lib/playbook/plugin/playbook/Entry.js b/lib/playbook/plugin/playbook/Entry.js
index 5e03441..47f8572 100644
--- a/lib/playbook/plugin/playbook/Entry.js
+++ b/lib/playbook/plugin/playbook/Entry.js
@@ -80,26 +80,28 @@ module.exports = {
                 }
             };
 
+        // Entry object is borked for some reason - unable to instantiate a new Entry object so just create one
         var theEntry = {};
+        var dstPath = parent.fullPath + '/' + name;
         if(this.isFile){
-            if(srcPath != parent.fullPath + '/' + name){
-                if(blackberry.io.file.exists(parent.fullPath + '/' + name)){
-                    blackberry.io.file.deleteFile(parent.fullPath + '/' + name);
-                    blackberry.io.file.copy(srcPath,parent.fullPath + '/' + name);
+            if(srcPath != dstPath){
+                if(blackberry.io.file.exists(dstPath)){
+                    blackberry.io.file.deleteFile(dstPath);
+                    blackberry.io.file.copy(srcPath,dstPath);
 
-                    theEntry.fullPath = parent.fullPath + '/' + name;
+                    theEntry.fullPath = dstPath;
                     theEntry.name = name;
                     theEntry.isDirectory = false;
                     theEntry.isFile = true;
                     success(theEntry);
 
-                }else if(blackberry.io.dir.exists(parent.fullPath + '/' + name)){
+                }else if(blackberry.io.dir.exists(dstPath)){
                     fail(FileError.INVALID_MODIFICATION_ERR);
                 }else{
-                    blackberry.io.file.copy(srcPath,parent.fullPath + '/' + name);
+                    blackberry.io.file.copy(srcPath,dstPath);
                     blackberry.io.file.deleteFile(srcPath);
 
-                    theEntry.fullPath = parent.fullPath + '/' + name;
+                    theEntry.fullPath = dstPath;
                     theEntry.name = name;
                     theEntry.isDirectory = false;
                     theEntry.isFile = true;
@@ -110,14 +112,14 @@ module.exports = {
                 fail(FileError.INVALID_MODIFICATION_ERR);
             }
         }else{
-            if(srcPath != parent.fullPath + '/' + name){
-                if(blackberry.io.dir.exists(parent.fullPath + '/' + name) || blackberry.io.file.exists(parent.fullPath + '/' + name) || srcPath == parent.fullPath){
+            if(srcPath != dstPath){
+                if(blackberry.io.dir.exists(dstPath) || blackberry.io.file.exists(dstPath) || srcPath == parent.fullPath){
                     fail(FileError.INVALID_MODIFICATION_ERR);
                 }else{
-                    blackberry.io.dir.createNewDir(parent.fullPath + '/' + name);
-                    recursiveCopy(srcPath,parent.fullPath + '/' + name);
+                    blackberry.io.dir.createNewDir(dstPath);
+                    recursiveCopy(srcPath,dstPath);
                     blackberry.io.dir.deleteDirectory(srcPath, true);
-                    theEntry.fullPath = parent.fullPath + '/' + name;
+                    theEntry.fullPath = dstPath;
                     theEntry.name = name;
                     theEntry.isDirectory = true;
                     theEntry.isFile = false;
@@ -165,16 +167,16 @@ module.exports = {
                 }
             };
 
-
-
+        // Entry object is borked for some reason - unable to instantiate a new Entry object so just create one
         var theEntry = {};
+        var dstPath = parent.fullPath + '/' + name;
         if(this.isFile){
-            if(srcPath != parent.fullPath + '/' + name){
-                if(blackberry.io.file.exists(parent.fullPath + '/' + name)){
-                    if(blackberry.io.dir.exists(parent.fullPath + '/' + name)){
-                        blackberry.io.file.copy(srcPath,parent.fullPath + '/' + name);
+            if(srcPath != dstPath){
+                if(blackberry.io.file.exists(dstPath)){
+                    if(blackberry.io.dir.exists(dstPath)){
+                        blackberry.io.file.copy(srcPath,dstPath);
 
-                        theEntry.fullPath = parent.fullPath + '/' + name;
+                        theEntry.fullPath = dstPath;
                         theEntry.name = name;
                         theEntry.isDirectory = false;
                         theEntry.isFile = true;
@@ -184,9 +186,9 @@ module.exports = {
                     }
 
                 }else{
-                    blackberry.io.file.copy(srcPath,parent.fullPath + '/' + name);
+                    blackberry.io.file.copy(srcPath,dstPath);
 
-                    theEntry.fullPath = parent.fullPath + '/' + name;
+                    theEntry.fullPath = dstPath;
                     theEntry.name = name;
                     theEntry.isDirectory = false;
                     theEntry.isFile = true;
@@ -197,32 +199,18 @@ module.exports = {
                 fail(FileError.INVALID_MODIFICATION_ERR);
             }
         }else{
-            if(srcPath != parent.fullPath + '/' + name){
-                var destPath = parent.fullPath + '/' + name;
-                if(destPath.indexOf(srcPath)>=0 || blackberry.io.file.exists(parent.fullPath + '/' + name)){
-                    fail(FileError.INVALID_MODIFICATION_ERR);
-                }else{
-                    recursiveCopy(srcPath, parent.fullPath + '/' + name);
-
-                    theEntry.fullPath = parent.fullPath + '/' + name;
-                    theEntry.name = name;
-                    theEntry.isDirectory = true;
-                    theEntry.isFile = false;
-                    success(theEntry);
-                }
-                /*
-                if(blackberry.io.dir.exists(parent.fullPath + '/' + name)){
+            if(srcPath != dstPath){
+                if(dstPath.indexOf(srcPath)>=0 || blackberry.io.file.exists(dstPath)){
                     fail(FileError.INVALID_MODIFICATION_ERR);
                 }else{
-                    blackberry.io.dir.createNewDir(parent.fullPath + '/' + name);
+                    recursiveCopy(srcPath, dstPath);
 
-                    theEntry.fullPath = parent.fullPath + '/' + name;
+                    theEntry.fullPath = dstPath;
                     theEntry.name = name;
                     theEntry.isDirectory = true;
                     theEntry.isFile = false;
                     success(theEntry);
                 }
-                */
             }else{
                 console.log('directory onto itself');
                 fail(FileError.INVALID_MODIFICATION_ERR);