Fixed bug in FileProxy.js
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/a1c3b6fc Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/tree/a1c3b6fc Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/diff/a1c3b6fc Branch: refs/heads/master Commit: a1c3b6fc8661b34198313bf00d7e26f097c1869c Parents: bb85ff1 Author: mpberk <matthew.p.b...@intel.com> Authored: Thu Aug 30 09:08:27 2012 -0700 Committer: mpberk <matthew.p.b...@intel.com> Committed: Thu Aug 30 09:08:27 2012 -0700 ---------------------------------------------------------------------- lib/windows8/plugin/windows8/FileProxy.js | 60 ++++++++++++------------ 1 files changed, 30 insertions(+), 30 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/a1c3b6fc/lib/windows8/plugin/windows8/FileProxy.js ---------------------------------------------------------------------- diff --git a/lib/windows8/plugin/windows8/FileProxy.js b/lib/windows8/plugin/windows8/FileProxy.js index 6ceef36..bbc03b4 100644 --- a/lib/windows8/plugin/windows8/FileProxy.js +++ b/lib/windows8/plugin/windows8/FileProxy.js @@ -6,7 +6,7 @@ var cordova = require('cordova'), module.exports = { //Merges with common getFileMetaData:function(win,fail,args) { - + Windows.Storage.StorageFile.getFileFromPathAsync(args[0]).done( function (storageFile) { @@ -67,11 +67,11 @@ module.exports = { //Merges with common getParent:function(win,fail,args) { // ["fullPath"] var fullPath = args[0]; - - + + var storageFolderPer = Windows.Storage.ApplicationData.current.localFolder; var storageFolderTem = Windows.Storage.ApplicationData.current.temporaryFolder; - + if (fullPath == FileSystemPersistentRoot) { win(new DirectoryEntry(storageFolderPer.name, storageFolderPer.path)); return; @@ -80,9 +80,9 @@ module.exports = { //Merges with common return; } var splitArr = fullPath.split(new RegExp(/\/|\\/g)); - + var popItem = splitArr.pop(); - + var result = new DirectoryEntry(popItem, fullPath.substr(0, fullPath.length - popItem.length - 1)); Windows.Storage.StorageFolder.getFolderFromPathAsync(result.fullPath).done( function () { win(result) }, @@ -116,7 +116,7 @@ module.exports = { //Merges with common }, readAsDataURL:function(win,fail,args) { - + Windows.Storage.StorageFile.getFileFromPathAsync(args[0]).then( function (storageFile) { @@ -206,10 +206,10 @@ module.exports = { //Merges with common }); } if (this.isDirectory) { - + var removeEntry = function () { var storageFolder = null; - + Windows.Storage.StorageFolder.getFolderFromPathAsync(fullPath).then(function (storageFolder) { //FileSystem root can't be removed! var storageFolderPer = Windows.Storage.ApplicationData.current.localFolder; @@ -241,8 +241,8 @@ module.exports = { //Merges with common fail(FileError.INVALID_MODIFICATION_ERR); }) - - + + } removeEntry(); } @@ -266,7 +266,7 @@ module.exports = { //Merges with common Windows.Storage.StorageFolder.getFolderFromPathAsync(path).then(function (storageFolder) { var fileListPromise = storageFolder.createFileQuery().getFilesAsync(); var filePromiseArr = []; - + fileListPromise.then(function (fileList) { if (fileList != null) { for (var i = 0; i < fileList.length; i++) { @@ -280,7 +280,7 @@ module.exports = { //Merges with common var folderPromiseArr = []; if (folderList.length != 0) { for (var j = 0; j < folderList.length; j++) { - + folderPromiseArr.push(removeFolders(folderList[j].path)); } WinJS.Promise.join(folderPromiseArr).then(function () { @@ -294,10 +294,10 @@ module.exports = { //Merges with common }, function () { }) }); }); - } + } removeFolders(storageFolder.path).then(function () { Windows.Storage.StorageFolder.getFolderFromPathAsync(storageFolder.path).then( - function () {}, + function () {}, function () { if (typeof successCallback != 'undefined' && successCallback != null) { successCallback(); } }) @@ -357,7 +357,7 @@ module.exports = { //Merges with common }, readEntries:function(win,fail,args) { // ["fullPath"] - + var result = new Array(); var path = args[0]; @@ -411,7 +411,7 @@ module.exports = { //Merges with common Windows.Storage.StorageFile.getFileFromPathAsync(fileName).done(function(storageFile){ //the current length of the file. var leng = 0; - + storageFile.getBasicPropertiesAsync().then(function (basicProperties) { leng = basicProperties.size; if (Number(size) >= leng) { @@ -451,7 +451,7 @@ module.exports = { //Merges with common copyTo:function(win,fail,args) { // ["fullPath","parent", "newName"] var srcPath = args[0]; - var parent.fullPath = args[1]; + var parentFullPath = args[1]; var name = args[2]; //name can't be invalid @@ -466,18 +466,18 @@ module.exports = { //Merges with common Windows.Storage.StorageFile.getFileFromPathAsync(srcPath).then(function (storageFile) { Windows.Storage.StorageFolder.getFolderFromPathAsync(parentPath).then(function (storageFolder) { storageFile.copyAsync(storageFolder, name, Windows.Storage.NameCollisionOption.failIfExists).then(function (storageFile) { - + success(new FileEntry(storageFile.name, storageFile.path)); }, function () { - + fail(FileError.INVALID_MODIFICATION_ERR); }); }, function () { - + fail(FileError.NOT_FOUND_ERR); }); }, function () { - + fail(FileError.NOT_FOUND_ERR); }) }; @@ -555,15 +555,15 @@ module.exports = { //Merges with common }, function () { fail(FileError.INVALID_MODIFICATION_ERR);}) } }; - copyFinish(srcPath, parent.fullPath); + copyFinish(srcPath, parentFullPath); }, moveTo:function(win,fail,args) { // ["fullPath","parent", "newName"] var srcPath = args[0]; - var parent.fullPath = args[1]; + var parentFullPath = args[1]; var name = args[2]; - + //name can't be invalid if (/\?|\\|\*|\||\"|<|>|\:|\//g.test(name)) { fail(FileError.ENCODING_ERR); @@ -571,7 +571,7 @@ module.exports = { //Merges with common }; var moveFiles = ""; - + if (this.isFile) { moveFiles = function (srcPath, parentPath) { @@ -632,7 +632,7 @@ module.exports = { //Merges with common }) } } - + // move var isDirectory = this.isDirectory; var isFile = this.isFile; @@ -644,7 +644,7 @@ module.exports = { //Merges with common fail(FileError.INVALID_MODIFICATION_ERR); return; } - moveFiles(srcPath, parent.fullPath); + moveFiles(srcPath, parentFullPath); } if (isDirectory) { Windows.Storage.StorageFolder.getFolderFromPathAsync(srcPath).then(function (originFolder) { @@ -670,7 +670,7 @@ module.exports = { //Merges with common moveFiles(srcPath, newStorageFolder.path).then(function () { var successCallback = function () { success(new DirectoryEntry(name, newStorageFolder.path)); } new DirectoryEntry(originFolder.name, originFolder.path).removeRecursively(successCallback, fail); - + }, function () { console.log("error!"); }); }) }) @@ -679,7 +679,7 @@ module.exports = { //Merges with common }, function () { fail(FileError.INVALID_MODIFICATION_ERR); }); } }; - moveFinish(srcPath, parent.fullPath); + moveFinish(srcPath, parentFullPath); }, tempFileSystem:null,