incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tim...@apache.org
Subject [10/48] js commit: fixed moving directory onto empty directory
Date Thu, 07 Jun 2012 20:40:43 GMT
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 <tim.kim@nitobi.com>
Authored: Thu May 31 12:29:35 2012 -0700
Committer: Tim Kim <tim.kim@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');


Mime
View raw message