incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tim...@apache.org
Subject [27/48] js commit: Got some move functions working
Date Thu, 07 Jun 2012 20:40:44 GMT
Got some move functions working


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

Branch: refs/heads/master
Commit: c0fcfafdaa4bb764cfd66930ba0d55ebe9feeebc
Parents: 0390bf6
Author: Tim Kim <tim.kim@nitobi.com>
Authored: Tue May 22 16:40:18 2012 -0700
Committer: Tim Kim <tim.kim@nitobi.com>
Committed: Thu Jun 7 13:40:23 2012 -0700

----------------------------------------------------------------------
 lib/playbook/plugin/playbook/Entry.js |   44 ++++++++++++++++++++-------
 1 files changed, 32 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/c0fcfafd/lib/playbook/plugin/playbook/Entry.js
----------------------------------------------------------------------
diff --git a/lib/playbook/plugin/playbook/Entry.js b/lib/playbook/plugin/playbook/Entry.js
index 7295cc6..478868b 100644
--- a/lib/playbook/plugin/playbook/Entry.js
+++ b/lib/playbook/plugin/playbook/Entry.js
@@ -1,6 +1,8 @@
 var FileError = require('cordova/plugin/FileError'),
     LocalFileSystem = require('cordova/plugin/LocalFileSystem'),
-    resolveLocalFileSystemURI = require('cordova/plugin/resolveLocalFileSystemURI');
+    resolveLocalFileSystemURI = require('cordova/plugin/resolveLocalFileSystemURI'),
+    DirectoryEntry = require('cordova/plugin/DirectoryEntry'),
+    FileEntry = require('cordova/plugin/FileEntry');
 
 module.exports = {
     getMetadata : function(successCallback, errorCallback){
@@ -42,7 +44,7 @@ module.exports = {
                 if (entry) {
                     if (typeof successCallback === 'function') {
                         // create appropriate Entry object
-                        var result = (entry.isDirectory) ? new (require('cordova/plugin/playbook/DirectoryEntry'))(entry.name,
entry.fullPath) : new (require('cordova/plugin/playbook/FileEntry'))(entry.name, entry.fullPath);
+                        var result = (entry.isDirectory) ? new DirectoryEntry(entry.name,
entry.fullPath) : new FileEntry(entry.name, entry.fullPath);
                         try {
                             successCallback(result);
                         }
@@ -57,22 +59,40 @@ module.exports = {
                 }
             };
 
+        var theEntry = {};
         if(this.isFile){
-            if(blackberry.io.file.exists(parent + newName)){
-                // overwrite file
+            if(blackberry.io.file.exists(parent.fullPath + '/' + name)){
+                blackberry.io.file.deleteFile(parent.fullPath + '/' + name);
+                blackberry.io.file.copy(srcPath,parent.fullPath + '/' + name);
+
+                theEntry.fullPath = parent.fullPath + '/' + name;
+                theEntry.name = name;
+                theEntry.isDirectory = false;
+                theEntry.isFile = true;
+                success(theEntry);
 
             }else{
-                console.log('this.srcPath: ' + this.srcPath);
-                console.log('newName: ' + newName);
-                blackberry.io.file.copy(this.srcPath,parent+newName);
-                blackberry.io.deleteFile(this.srcPath);
+                blackberry.io.file.copy(srcPath,parent.fullPath + '/' + name);
+                blackberry.io.file.deleteFile(srcPath);
+
+                theEntry.fullPath = parent.fullPath + '/' + name;
+                theEntry.name = name;
+                theEntry.isDirectory = false;
+                theEntry.isFile = true;
+                success(theEntry);
             }
         }else{
-            if(blackberry.io.dir.exists(parent + newName)){
-                fail(FileError.NO_MODIFICATION_ALLOWED_ERR);
+            if(blackberry.io.dir.exists(parent.fullPath + '/' + name)){
+                fail(FileError.INVALID_MODIFICATION_ERROR);
             }else{
-                blackberry.io.dir.createNewDir(parent + newName);
-                blackberry.io.dir.deleteDirectory(this.srcPath);
+                blackberry.io.dir.createNewDir(parent.fullPath + '/' + name);
+                blackberry.io.dir.deleteDirectory(srcPath);
+
+                theEntry.fullPath = parent.fullPath + '/' + name;
+                theEntry.name = name;
+                theEntry.isDirectory = true;
+                theEntry.isFile = false;
+                success(theEntry);
             }
         }
 


Mime
View raw message