[windows8] fail may not be defined
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/b7ada77c Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/tree/b7ada77c Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/diff/b7ada77c Branch: refs/heads/master Commit: b7ada77c65db5bf79a759031e0c772a722d02130 Parents: 6f2ac07 Author: Jesse MacFadyen <purplecabb...@gmail.com> Authored: Thu Oct 18 17:17:22 2012 -0700 Committer: Jesse MacFadyen <purplecabb...@gmail.com> Committed: Thu Oct 18 17:17:22 2012 -0700 ---------------------------------------------------------------------- lib/windows8/plugin/windows8/FileProxy.js | 120 ++++++++++++------------ 1 files changed, 60 insertions(+), 60 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/b7ada77c/lib/windows8/plugin/windows8/FileProxy.js ---------------------------------------------------------------------- diff --git a/lib/windows8/plugin/windows8/FileProxy.js b/lib/windows8/plugin/windows8/FileProxy.js index 87af738..12d6a99 100644 --- a/lib/windows8/plugin/windows8/FileProxy.js +++ b/lib/windows8/plugin/windows8/FileProxy.js @@ -42,11 +42,11 @@ module.exports = { function (basicProperties) { win(new File(storageFile.name, storageFile.path, storageFile.fileType, basicProperties.dateModified, basicProperties.size)); }, function () { - fail(FileError.NOT_READABLE_ERR); + fail && fail(FileError.NOT_READABLE_ERR); } ); }, function () { - fail(FileError.NOT_FOUND_ERR); + fail && fail(FileError.NOT_FOUND_ERR); } ); }, @@ -60,7 +60,7 @@ module.exports = { return storageFile.getBasicPropertiesAsync(); }, function () { - fail(FileError.NOT_READABLE_ERR); + fail && fail(FileError.NOT_READABLE_ERR); } // get the basic properties of the file. ).then( @@ -68,7 +68,7 @@ module.exports = { success(basicProperties.dateModified); }, function () { - fail(FileError.NOT_READABLE_ERR); + fail && fail(FileError.NOT_READABLE_ERR); } ); }; @@ -79,7 +79,7 @@ module.exports = { return storageFolder.getBasicPropertiesAsync(); }, function () { - fail(FileError.NOT_READABLE_ERR); + fail && fail(FileError.NOT_READABLE_ERR); } // get the basic properties of the folder. ).then( @@ -87,7 +87,7 @@ module.exports = { success(basicProperties.dateModified); }, function () { - fail(FileError.NOT_FOUND_ERR); + fail && fail(FileError.NOT_FOUND_ERR); } ); }; @@ -103,7 +103,7 @@ module.exports = { function (sFolder) { dealFolder(sFolder); }, function () { - fail(FileError.NOT_FOUND_ERR); + fail && fail(FileError.NOT_FOUND_ERR); } ); } @@ -130,7 +130,7 @@ module.exports = { var result = new DirectoryEntry(popItem, fullPath.substr(0, fullPath.length - popItem.length - 1)); Windows.Storage.StorageFolder.getFolderFromPathAsync(result.fullPath).done( function () { win(result); }, - function () { fail(FileError.INVALID_STATE_ERR); } + function () { fail && fail(FileError.INVALID_STATE_ERR); } ); }, @@ -151,11 +151,11 @@ module.exports = { win(fileContent); }, function () { - fail(FileError.ENCODING_ERR); + fail && fail(FileError.ENCODING_ERR); } ); }, function () { - fail(FileError.NOT_FOUND_ERR); + fail && fail(FileError.NOT_FOUND_ERR); } ); }, @@ -179,7 +179,7 @@ module.exports = { } ); }, function () { - fail(FileError.NOT_FOUND_ERR); + fail && fail(FileError.NOT_FOUND_ERR); } ); }, @@ -205,7 +205,7 @@ module.exports = { function (storageFolder) { win(new DirectoryEntry(storageFolder.name, storageFolder.path)); }, function () { - fail(FileError.PATH_EXISTS_ERR); + fail && fail(FileError.PATH_EXISTS_ERR); } ); } else if (flag.create === true && flag.exclusive === false) { @@ -213,12 +213,12 @@ module.exports = { function (storageFolder) { win(new DirectoryEntry(storageFolder.name, storageFolder.path)); }, function () { - fail(FileError.INVALID_MODIFICATION_ERR); + fail && fail(FileError.INVALID_MODIFICATION_ERR); } ); } else if (flag.create === false) { if (/\?|\\|\*|\||\"|<|>|\:|\//g.test(path)) { - fail(FileError.ENCODING_ERR); + fail && fail(FileError.ENCODING_ERR); return; } @@ -226,12 +226,12 @@ module.exports = { function (storageFolder) { win(new DirectoryEntry(storageFolder.name, storageFolder.path)); }, function () { - fail(FileError.NOT_FOUND_ERR); + fail && fail(FileError.NOT_FOUND_ERR); } ); } }, function () { - fail(FileError.NOT_FOUND_ERR); + fail && fail(FileError.NOT_FOUND_ERR); } ); }, @@ -243,7 +243,7 @@ module.exports = { function (sFile) { Windows.Storage.StorageFile.getFileFromPathAsync(fullPath).done(function (storageFile) { storageFile.deleteAsync().done(win, function () { - fail(FileError.INVALID_MODIFICATION_ERR); + fail && fail(FileError.INVALID_MODIFICATION_ERR); }); }); @@ -260,13 +260,13 @@ module.exports = { var storageFolderPer = Windows.Storage.ApplicationData.current.localFolder; var storageFolderTem = Windows.Storage.ApplicationData.current.temporaryFolder; if (fullPath == storageFolderPer.path || fullPath == storageFolderTem.path) { - fail(FileError.NO_MODIFICATION_ALLOWED_ERR); + fail && fail(FileError.NO_MODIFICATION_ALLOWED_ERR); return; } storageFolderTop = storageFolder; return storageFolder.createFileQuery().getFilesAsync(); }, function () { - fail(FileError.INVALID_MODIFICATION_ERR); + fail && fail(FileError.INVALID_MODIFICATION_ERR); } // check sub-files. @@ -275,7 +275,7 @@ module.exports = { if (fileList.length === 0) { return storageFolderTop.createFolderQuery().getFoldersAsync(); } else { - fail(FileError.INVALID_MODIFICATION_ERR); + fail && fail(FileError.INVALID_MODIFICATION_ERR); } } // check sub-folders. @@ -283,11 +283,11 @@ module.exports = { if (folderList) { if (folderList.length === 0) { storageFolderTop.deleteAsync().done(win, function () { - fail(FileError.INVALID_MODIFICATION_ERR); + fail && fail(FileError.INVALID_MODIFICATION_ERR); }); } else { - fail(FileError.INVALID_MODIFICATION_ERR); + fail && fail(FileError.INVALID_MODIFICATION_ERR); } } @@ -295,7 +295,7 @@ module.exports = { }; removeEntry(); }, function () { - fail(FileError.NOT_FOUND_ERR); + fail && fail(FileError.NOT_FOUND_ERR); } ); } @@ -310,7 +310,7 @@ module.exports = { var storageFolderTem = Windows.Storage.ApplicationData.current.temporaryFolder; if (storageFolder.path == storageFolderPer.path || storageFolder.path == storageFolderTem.path) { - fail(FileError.NO_MODIFICATION_ALLOWED_ERR); + fail && fail(FileError.NO_MODIFICATION_ALLOWED_ERR); return; } @@ -385,7 +385,7 @@ module.exports = { function (storageFile) { win(new FileEntry(storageFile.name, storageFile.path)); }, function () { - fail(FileError.PATH_EXISTS_ERR); + fail && fail(FileError.PATH_EXISTS_ERR); } ); } else if (flag.create === true && flag.exclusive === false) { @@ -393,24 +393,24 @@ module.exports = { function (storageFile) { win(new FileEntry(storageFile.name, storageFile.path)); }, function () { - fail(FileError.INVALID_MODIFICATION_ERR); + fail && fail(FileError.INVALID_MODIFICATION_ERR); } ); } else if (flag.create === false) { if (/\?|\\|\*|\||\"|<|>|\:|\//g.test(path)) { - fail(FileError.ENCODING_ERR); + fail && fail(FileError.ENCODING_ERR); return; } storageFolder.getFileAsync(path).done( function (storageFile) { win(new FileEntry(storageFile.name, storageFile.path)); }, function () { - fail(FileError.NOT_FOUND_ERR); + fail && fail(FileError.NOT_FOUND_ERR); } ); } }, function () { - fail(FileError.NOT_FOUND_ERR); + fail && fail(FileError.NOT_FOUND_ERR); } ); }, @@ -441,7 +441,7 @@ module.exports = { win(result); }); - }, function () { fail(FileError.NOT_FOUND_ERR); }); + }, function () { fail && fail(FileError.NOT_FOUND_ERR); }); }, write:function(win,fail,args) { @@ -455,11 +455,11 @@ module.exports = { function() { win(String(text).length); }, function () { - fail(FileError.INVALID_MODIFICATION_ERR); + fail && fail(FileError.INVALID_MODIFICATION_ERR); } ); }, function() { - fail(FileError.NOT_FOUND_ERR); + fail && fail(FileError.NOT_FOUND_ERR); } ); }, @@ -494,16 +494,16 @@ module.exports = { Windows.Storage.FileIO.writeTextAsync(newStorageFile, fileContent).done(function () { win(String(fileContent).length); }, function () { - fail(FileError.NO_MODIFICATION_ALLOWED_ERR); + fail && fail(FileError.NO_MODIFICATION_ALLOWED_ERR); }); }); }); }; entry.getParent(successCallBack, null); - }, function () { fail(FileError.NOT_FOUND_ERR); }); + }, function () { fail && fail(FileError.NOT_FOUND_ERR); }); } }); - }, function () { fail(FileError.NOT_FOUND_ERR); }); + }, function () { fail && fail(FileError.NOT_FOUND_ERR); }); }, copyTo:function(success,fail,args) { // ["fullPath","parent", "newName"] @@ -513,7 +513,7 @@ module.exports = { //name can't be invalid if (/\?|\\|\*|\||\"|<|>|\:|\//g.test(name)) { - fail(FileError.ENCODING_ERR); + fail && fail(FileError.ENCODING_ERR); return; } // copy @@ -527,18 +527,18 @@ module.exports = { return Windows.Storage.StorageFolder.getFolderFromPathAsync(parentPath); }, function () { - fail(FileError.NOT_FOUND_ERR); + fail && fail(FileError.NOT_FOUND_ERR); }).then(function (storageFolder) { storageFileTop.copyAsync(storageFolder, name, Windows.Storage.NameCollisionOption.failIfExists).then(function (storageFile) { success(new FileEntry(storageFile.name, storageFile.path)); }, function () { - fail(FileError.INVALID_MODIFICATION_ERR); + fail && fail(FileError.INVALID_MODIFICATION_ERR); }); }, function () { - fail(FileError.NOT_FOUND_ERR); + fail && fail(FileError.NOT_FOUND_ERR); }); }; var copyFinish = function (srcPath, parentPath) { @@ -598,12 +598,12 @@ module.exports = { storageFolder.createFolderAsync(name, Windows.Storage.CreationCollisionOption.openIfExists).then(function (newStorageFolder) { //can't copy onto itself if (srcPath == newStorageFolder.path) { - fail(FileError.INVALID_MODIFICATION_ERR); + fail && fail(FileError.INVALID_MODIFICATION_ERR); return; } //can't copy into itself if (srcPath == parentPath) { - fail(FileError.INVALID_MODIFICATION_ERR); + fail && fail(FileError.INVALID_MODIFICATION_ERR); return; } copyFiles(srcPath, newStorageFolder.path).then(function () { @@ -611,15 +611,15 @@ module.exports = { function (storageFolder) { success(new DirectoryEntry(storageFolder.name, storageFolder.path)); }, - function () { fail(FileError.NOT_FOUND_ERR); } + function () { fail && fail(FileError.NOT_FOUND_ERR); } ); }); - }, function () { fail(FileError.INVALID_MODIFICATION_ERR); }); - }, function () { fail(FileError.INVALID_MODIFICATION_ERR); }); + }, function () { fail && fail(FileError.INVALID_MODIFICATION_ERR); }); + }, function () { fail && fail(FileError.INVALID_MODIFICATION_ERR); }); }; copyFinish(srcPath, parentFullPath); }, function () { - fail(FileError.NOT_FOUND_ERR); + fail && fail(FileError.NOT_FOUND_ERR); } ); } @@ -634,7 +634,7 @@ module.exports = { //name can't be invalid if (/\?|\\|\*|\||\"|<|>|\:|\//g.test(name)) { - fail(FileError.ENCODING_ERR); + fail && fail(FileError.ENCODING_ERR); return; } @@ -647,21 +647,21 @@ module.exports = { storageFileTop = storageFile; return Windows.Storage.StorageFolder.getFolderFromPathAsync(parentPath); }, function () { - fail(FileError.NOT_FOUND_ERR); + fail && fail(FileError.NOT_FOUND_ERR); }).then(function (storageFolder) { storageFileTop.moveAsync(storageFolder, name, Windows.Storage.NameCollisionOption.replaceExisting).then(function () { success(new FileEntry(name, storageFileTop.path)); }, function () { - fail(FileError.INVALID_MODIFICATION_ERR); + fail && fail(FileError.INVALID_MODIFICATION_ERR); }); }, function () { - fail(FileError.NOT_FOUND_ERR); + fail && fail(FileError.NOT_FOUND_ERR); }); }; var moveFinish = function (srcPath, parentPath) { //can't copy onto itself if (srcPath == parentPath + "\\" + name) { - fail(FileError.INVALID_MODIFICATION_ERR); + fail && fail(FileError.INVALID_MODIFICATION_ERR); return; } moveFiles(srcPath, parentFullPath); @@ -721,27 +721,27 @@ module.exports = { originFolderTop = originFolder; return Windows.Storage.StorageFolder.getFolderFromPathAsync(parentPath); }, function () { - fail(FileError.INVALID_MODIFICATION_ERR); + fail && fail(FileError.INVALID_MODIFICATION_ERR); }).then(function (storageFolder) { return storageFolder.createFolderAsync(name, Windows.Storage.CreationCollisionOption.openIfExists); }, function () { - fail(FileError.INVALID_MODIFICATION_ERR); + fail && 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); + fail && fail(FileError.INVALID_MODIFICATION_ERR); return; } //can't copy onto itself if (srcPath == newStorageFolder.path) { - fail(FileError.INVALID_MODIFICATION_ERR); + fail && fail(FileError.INVALID_MODIFICATION_ERR); return; } //can't copy into itself if (srcPath == parentPath) { - fail(FileError.INVALID_MODIFICATION_ERR); + fail && fail(FileError.INVALID_MODIFICATION_ERR); return; } moveFiles(srcPath, newStorageFolder.path).then(function () { @@ -753,12 +753,12 @@ module.exports = { }, function () { console.log("error!"); }); }); }); - }, function () { fail(FileError.INVALID_MODIFICATION_ERR); }); + }, function () { fail && fail(FileError.INVALID_MODIFICATION_ERR); }); }; moveFinish(srcPath, parentFullPath); }, function () { - fail(FileError.NOT_FOUND_ERR); + fail && fail(FileError.NOT_FOUND_ERR); } ); } @@ -789,7 +789,7 @@ module.exports = { var MAX_SIZE = 10000000000; if (size > MAX_SIZE) { - fail(FileError.QUOTA_EXCEEDED_ERR); + fail && fail(FileError.QUOTA_EXCEEDED_ERR); return; } @@ -825,7 +825,7 @@ module.exports = { function (storageFolder) { success(new DirectoryEntry(storageFolder.name, storageFolder.path)); }, function () { - fail(FileError.NOT_FOUND_ERR); + fail && fail(FileError.NOT_FOUND_ERR); } ); } @@ -839,7 +839,7 @@ module.exports = { function (storageFolder) { success(new DirectoryEntry(storageFolder.name, storageFolder.path)); }, function () { - fail(FileError.ENCODING_ERR); + fail && fail(FileError.ENCODING_ERR); } ); }