modify moveTo method

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

Branch: refs/heads/master
Commit: 3fdb1e19d2f6c403a337db64d4c5984a54d0fd1e
Parents: 6c51119
Author: wangmingfeng <mingfengwan...@gmail.com>
Authored: Thu Oct 11 16:55:47 2012 +0800
Committer: wangmingfeng <mingfengwan...@gmail.com>
Committed: Thu Oct 11 16:55:47 2012 +0800

----------------------------------------------------------------------
 lib/windows8/plugin/windows8/FileProxy.js |   67 +++++++++++++-----------
 1 files changed, 36 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/3fdb1e19/lib/windows8/plugin/windows8/FileProxy.js
----------------------------------------------------------------------
diff --git a/lib/windows8/plugin/windows8/FileProxy.js 
b/lib/windows8/plugin/windows8/FileProxy.js
index 3b48036..06be506 100644
--- a/lib/windows8/plugin/windows8/FileProxy.js
+++ b/lib/windows8/plugin/windows8/FileProxy.js
@@ -692,37 +692,43 @@ module.exports = {
                             });
                         };
                         var moveFinish = function (srcPath, parentPath) {
+                            var originFolderTop = null;
                             
Windows.Storage.StorageFolder.getFolderFromPathAsync(srcPath).then(function 
(originFolder) {
-                                return 
Windows.Storage.StorageFolder.getFolderFromPathAsync(parentPath).then(function 
(storageFolder) {
-                                    storageFolder.createFolderAsync(name, 
Windows.Storage.CreationCollisionOption.openIfExists).then(function 
(newStorageFolder) {
-                                        //can't move onto directory that is 
not empty
-                                        
newStorageFolder.createFileQuery().getFilesAsync().then(function (fileList) {
-                                            
newStorageFolder.createFolderQuery().getFoldersAsync().then(function 
(folderList) {
-                                                if (fileList.length !== 0 || 
folderList.length !== 0) {
-                                                    
fail(FileError.INVALID_MODIFICATION_ERR);
-                                                    return;
-                                                }
-                                                //can't copy onto itself
-                                                if (srcPath == 
newStorageFolder.path) {
-                                                    
fail(FileError.INVALID_MODIFICATION_ERR);
-                                                    return;
-                                                }
-                                                //can't copy into itself
-                                                if (srcPath == parentPath) {
-                                                    
fail(FileError.INVALID_MODIFICATION_ERR);
-                                                    return;
-                                                }
-                                                moveFiles(srcPath, 
newStorageFolder.path).then(function () {
-                                                    var successCallback = 
function () {
-                                                        success(new 
DirectoryEntry(name, newStorageFolder.path));
-                                                        };
-                                                    var temp = new 
DirectoryEntry(originFolder.name, 
originFolder.path).removeRecursively(successCallback, fail);
-
-                                                }, function () { 
console.log("error!"); });
-                                            });
-                                        });
-                                    }, function () { 
fail(FileError.INVALID_MODIFICATION_ERR); });
-                                }, function () { 
fail(FileError.INVALID_MODIFICATION_ERR); });
+                                originFolderTop = originFolder;
+                                return 
Windows.Storage.StorageFolder.getFolderFromPathAsync(parentPath);
+                            }, function () {
+                                fail(FileError.INVALID_MODIFICATION_ERR);
+                            }).then(function (storageFolder) {
+                                return storageFolder.createFolderAsync(name, 
Windows.Storage.CreationCollisionOption.openIfExists);
+                            }, function () {
+                                fail(FileError.INVALID_MODIFICATION_ERR);
+                            }).then(function (newStorageFolder) {
+                                //can't move onto directory that is not empty
+                                
newStorageFolder.createFileQuery().getFilesAsync().then(function (fileList) {
+                                    
newStorageFolder.createFolderQuery().getFoldersAsync().then(function 
(folderList) {
+                                        if (fileList.length !== 0 || 
folderList.length !== 0) {
+                                            
fail(FileError.INVALID_MODIFICATION_ERR);
+                                            return;
+                                        }
+                                        //can't copy onto itself
+                                        if (srcPath == newStorageFolder.path) {
+                                            
fail(FileError.INVALID_MODIFICATION_ERR);
+                                            return;
+                                        }
+                                        //can't copy into itself
+                                        if (srcPath == parentPath) {
+                                            
fail(FileError.INVALID_MODIFICATION_ERR);
+                                            return;
+                                        }
+                                        moveFiles(srcPath, 
newStorageFolder.path).then(function () {
+                                            var successCallback = function () {
+                                                success(new 
DirectoryEntry(name, newStorageFolder.path));
+                                            };
+                                            var temp = new 
DirectoryEntry(originFolderTop.name, 
originFolderTop.path).removeRecursively(successCallback, fail);
+
+                                        }, function () { 
console.log("error!"); });
+                                    });
+                                });
                             }, function () { 
fail(FileError.INVALID_MODIFICATION_ERR); });
 
                         };
@@ -734,7 +740,6 @@ module.exports = {
             }
         );
     },
-
     tempFileSystem:null,
 
     persistentFileSystem:null,

Reply via email to