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:43 UTC

[10/48] js commit: fixed moving directory onto empty directory

fixed moving directory onto empty directory


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

Branch: refs/heads/master
Commit: e5b9cf2952051891f0f744c5984534b530918b42
Parents: 62c51ff
Author: Tim Kim <ti...@nitobi.com>
Authored: Thu May 31 12:29:35 2012 -0700
Committer: Tim Kim <ti...@nitobi.com>
Committed: Thu Jun 7 13:40:24 2012 -0700

----------------------------------------------------------------------
 lib/playbook/plugin/playbook/Entry.js |   36 +++++++++++++++++++++-------
 1 files changed, 27 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/e5b9cf29/lib/playbook/plugin/playbook/Entry.js
----------------------------------------------------------------------
diff --git a/lib/playbook/plugin/playbook/Entry.js b/lib/playbook/plugin/playbook/Entry.js
index 47f8572..d3f9819 100644
--- a/lib/playbook/plugin/playbook/Entry.js
+++ b/lib/playbook/plugin/playbook/Entry.js
@@ -113,17 +113,35 @@ module.exports = {
             }
         }else{
             if(srcPath != dstPath){
-                if(blackberry.io.dir.exists(dstPath) || blackberry.io.file.exists(dstPath) || srcPath == parent.fullPath){
+                if(blackberry.io.file.exists(dstPath) || srcPath == parent.fullPath){
                     fail(FileError.INVALID_MODIFICATION_ERR);
                 }else{
-                    blackberry.io.dir.createNewDir(dstPath);
-                    recursiveCopy(srcPath,dstPath);
-                    blackberry.io.dir.deleteDirectory(srcPath, true);
-                    theEntry.fullPath = dstPath;
-                    theEntry.name = name;
-                    theEntry.isDirectory = true;
-                    theEntry.isFile = false;
-                    success(theEntry);
+                    if(!blackberry.io.dir.exists(dstPath)){
+                        blackberry.io.dir.createNewDir(dstPath);
+                        recursiveCopy(srcPath,dstPath);
+                        blackberry.io.dir.deleteDirectory(srcPath, true);
+                        theEntry.fullPath = dstPath;
+                        theEntry.name = name;
+                        theEntry.isDirectory = true;
+                        theEntry.isFile = false;
+                        success(theEntry);
+                    }else{
+                        var numOfEntries = 0;
+                        numOfEntries += blackberry.io.dir.listDirectories(dstPath).length;
+                        numOfEntries += blackberry.io.dir.listFiles(dstPath).length;
+                        if(numOfEntries==0){
+                            blackberry.io.dir.createNewDir(dstPath);
+                            recursiveCopy(srcPath,dstPath);
+                            blackberry.io.dir.deleteDirectory(srcPath, true);
+                            theEntry.fullPath = dstPath;
+                            theEntry.name = name;
+                            theEntry.isDirectory = true;
+                            theEntry.isFile = false;
+                            success(theEntry);
+                        }else{
+                            fail(FileError.INVALID_MODIFICATION_ERR);
+                        }
+                    }
                 }
             }else{
                 console.log('directory onto itself');