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
[24/48] js commit: Recursive directory copy
Recursive directory copy
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/e12d5b84
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/tree/e12d5b84
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/diff/e12d5b84
Branch: refs/heads/master
Commit: e12d5b84c440064cbbd66033fb637386e415c398
Parents: 19a85ab
Author: Tim Kim <ti...@nitobi.com>
Authored: Wed May 23 15:57:30 2012 -0700
Committer: Tim Kim <ti...@nitobi.com>
Committed: Thu Jun 7 13:40:23 2012 -0700
----------------------------------------------------------------------
lib/playbook/plugin/playbook/Entry.js | 26 ++++++++++++++++++++++++++
1 files changed, 26 insertions(+), 0 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/e12d5b84/lib/playbook/plugin/playbook/Entry.js
----------------------------------------------------------------------
diff --git a/lib/playbook/plugin/playbook/Entry.js b/lib/playbook/plugin/playbook/Entry.js
index 2686a6f..3187523 100644
--- a/lib/playbook/plugin/playbook/Entry.js
+++ b/lib/playbook/plugin/playbook/Entry.js
@@ -142,6 +142,23 @@ module.exports = {
}
};
+ var recursiveCopy = function(srcDirPath, dstDirPath){
+ // get all the contents (file+dir) of the dir
+ var files = blackberry.io.dir.listFiles(srcDirPath);
+ var dirs = blackberry.io.dir.listDirectories(srcDirPath);
+
+ for(var i=0;i<files.length;i++){
+ blackberry.io.file.copy(srcDirPath + '/' + files[i], dstDirPath + '/' + files[i]);
+ }
+
+ for(var j=0;j<dirs.length;j++){
+ if(!blackberry.io.dir.exists(dstDirPath + '/' + dirs[j])){
+ blackberry.io.dir.createNewDir(dstDirPath + '/' + dirs[j]);
+ }
+ recursiveCopy(srcDirPath + '/' + dirs[j], dstDirPath + '/' + dirs[j]);
+ }
+ }
+
var theEntry = {};
if(this.isFile){
if(srcPath != parent.fullPath + '/' + name){
@@ -169,6 +186,14 @@ module.exports = {
}
}else{
if(srcPath != parent.fullPath + '/' + name){
+ 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)){
fail(FileError.INVALID_MODIFICATION_ERR);
}else{
@@ -180,6 +205,7 @@ module.exports = {
theEntry.isFile = false;
success(theEntry);
}
+ */
}else{
console.log('directory onto itself');
fail(FileError.INVALID_MODIFICATION_ERR);