You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pu...@apache.org on 2014/07/09 03:56:00 UTC

[1/7] git commit: Moved similar calls to be the same calls, aliased long namespaced functions

Repository: cordova-plugin-file
Updated Branches:
  refs/heads/master 5b978227d -> cc833d17c


Moved similar calls to be the same calls, aliased long namespaced functions


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/commit/ba142db1
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/tree/ba142db1
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/diff/ba142db1

Branch: refs/heads/master
Commit: ba142db12404a4b6f4ee4782157ad3029b4f85c8
Parents: 5b97822
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Tue Jul 8 15:39:44 2014 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Tue Jul 8 17:02:42 2014 -0700

----------------------------------------------------------------------
 src/windows8/FileProxy.js | 277 ++++++++++++++++++++---------------------
 1 file changed, 138 insertions(+), 139 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/ba142db1/src/windows8/FileProxy.js
----------------------------------------------------------------------
diff --git a/src/windows8/FileProxy.js b/src/windows8/FileProxy.js
index 333009b..d4ff33f 100644
--- a/src/windows8/FileProxy.js
+++ b/src/windows8/FileProxy.js
@@ -29,12 +29,36 @@ var Entry = require('./Entry'),
     FileSystem = require('./FileSystem'),
     LocalFileSystem = require('./LocalFileSystem');
 
+// Some private helper functions, hidden by the module
+function cordovaPathToNative(path) {
+    // turn / into \\
+    var cleanPath = path.replace(/\//g, '\\');
+    // turn  \\ into \
+    cleanPath = cleanPath.replace(/\\\\/g, '\\');
+    return cleanPath;
+};
+
+function nativePathToCordova(path) {
+    var cleanPath = path.replace(/\\/g, '/');s
+    return cleanPath;
+};
+
+function getFolderFromPathAsync(path) {
+    return Windows.Storage.StorageFolder.getFolderFromPathAsync(path);
+};
+
+function getFileFromPathAsync(path) {
+    return Windows.Storage.StorageFile.getFileFromPathAsync(path);
+};
+
+
 module.exports = {
 
-    getFileMetadata:function(win,fail,args) {
-        var fullPath = args[0];
+    getFileMetadata: function (win, fail, args) {
+
+        var fullPath = cordovaPathToNative(args[0]);
 
-        Windows.Storage.StorageFile.getFileFromPathAsync(fullPath).done(
+        getFileFromPathAsync(fullPath).done(
             function (storageFile) {
                 storageFile.getBasicPropertiesAsync().then(
                     function (basicProperties) {
@@ -49,11 +73,12 @@ module.exports = {
         );
     },
 
-    getMetadata:function(success,fail,args) {
-        var fullPath = args[0];
+    getMetadata: function (success, fail, args) {
+
+        var fullPath = cordovaPathToNative(args[0]);
 
         var dealFile = function (sFile) {
-            Windows.Storage.StorageFile.getFileFromPathAsync(fullPath).then(
+            getFileFromPathAsync(fullPath).then(
                 function (storageFile) {
                     return storageFile.getBasicPropertiesAsync();
                 },
@@ -72,7 +97,7 @@ module.exports = {
         };
 
         var dealFolder = function (sFolder) {
-            Windows.Storage.StorageFolder.getFolderFromPathAsync(fullPath).then(
+            getFolderFromPathAsync(fullPath).then(
                 function (storageFolder) {
                     return storageFolder.getBasicPropertiesAsync();
                 },
@@ -90,14 +115,14 @@ module.exports = {
             );
         };
 
-        Windows.Storage.StorageFile.getFileFromPathAsync(fullPath).then(
+        getFileFromPathAsync(fullPath).then(
             // the path is file.
             function (sFile) {
                 dealFile(sFile);
             },
             // the path is folder
             function () {
-                Windows.Storage.StorageFolder.getFolderFromPathAsync(fullPath).then(
+                getFolderFromPathAsync(fullPath).then(
                     function (sFolder) {
                         dealFolder(sFolder);
                     }, function () {
@@ -108,8 +133,9 @@ module.exports = {
         );
     },
 
-    getParent:function(win,fail,args) { // ["fullPath"]
-        var fullPath = args[0];
+    getParent: function (win, fail, args) { // ["fullPath"]
+
+        var fullPath = cordovaPathToNative(args[0]);
 
         var storageFolderPer = Windows.Storage.ApplicationData.current.localFolder;
         var storageFolderTem = Windows.Storage.ApplicationData.current.temporaryFolder;
@@ -126,14 +152,15 @@ module.exports = {
         var popItem = splitArr.pop();
 
         var result = new DirectoryEntry(popItem, fullPath.substr(0, fullPath.length - popItem.length - 1));
-        Windows.Storage.StorageFolder.getFolderFromPathAsync(result.fullPath).done(
+        getFolderFromPathAsync(result.fullPath).done(
             function () { win(result); },
             function () { fail && fail(FileError.INVALID_STATE_ERR); }
         );
     },
 
-    readAsText:function(win,fail,args) {
-        var fileName = args[0],
+    readAsText: function (win, fail, args) {
+
+        var fileName = cordovaPathToNative(args[0]),
             enc = args[1],
             startPos = args[2],
             endPos = args[3];
@@ -145,7 +172,7 @@ module.exports = {
             encoding = Windows.Storage.Streams.UnicodeEncoding.utf16BE;
         }
 
-        Windows.Storage.StorageFile.getFileFromPathAsync(fileName).then(function(file) {
+        getFileFromPathAsync(fileName).then(function(file) {
                 return file.openReadAsync();
             }).then(function (stream) {
                 startPos = (startPos < 0) ? Math.max(stream.size + startPos, 0) : Math.min(stream.size, startPos);
@@ -157,21 +184,18 @@ module.exports = {
 
                 return stream.readAsync(buffer, readSize, Windows.Storage.Streams.InputStreamOptions.none);
             }).done(function(buffer) {
-                try{
-                    win(Windows.Security.Cryptography.CryptographicBuffer.convertBinaryToString(encoding, buffer));
-                } catch (e) {
-                    fail && fail(FileError.ENCODING_ERR);
-                }
+                win(Windows.Security.Cryptography.CryptographicBuffer.convertBinaryToString(encoding, buffer));
             },function() {
                 fail && fail(FileError.NOT_FOUND_ERR);
             });
     },
 
-    readAsDataURL:function(win,fail,args) {
-        var fileName = args[0];
+    readAsDataURL: function (win, fail, args) {
 
+        var fileName = cordovaPathToNative(args[0]);
 
-        Windows.Storage.StorageFile.getFileFromPathAsync(fileName).then(
+
+        getFileFromPathAsync(fileName).then(
             function (storageFile) {
                 Windows.Storage.FileIO.readBufferAsync(storageFile).done(
                     function (buffer) {
@@ -191,50 +215,10 @@ module.exports = {
         );
     },
 
-    readAsBinaryString:function(win,fail,args) {
-        var fileName = args[0];
-
+    getDirectory: function (win, fail, args) {
 
-        Windows.Storage.StorageFile.getFileFromPathAsync(fileName).then(
-            function (storageFile) {
-                Windows.Storage.FileIO.readBufferAsync(storageFile).done(
-                    function (buffer) {
-			var dataReader = Windows.Storage.Streams.DataReader.fromBuffer(buffer);
-			var fileContent = dataReader.readString(buffer.length);
-			dataReader.close();
-			win(fileContent);
-                    }
-                );
-            }, function () {
-                fail && fail(FileError.NOT_FOUND_ERR);
-            }
-        );
-    },
-
-    readAsArrayBuffer:function(win,fail,args) {
-        var fileName = args[0];
-
-
-        Windows.Storage.StorageFile.getFileFromPathAsync(fileName).then(
-            function (storageFile) {
-            	var blob = MSApp.createFileFromStorageFile(storageFile);
-            	var url = URL.createObjectURL(blob, { oneTimeOnly: true });
-            	var xhr = new XMLHttpRequest();
-            	xhr.open("GET", url, true);
-            	xhr.responseType = 'arraybuffer';
-            	xhr.onload = function() {
-            	    win(xhr.response);
-            	};
-            	xhr.send();
-            }, function () {
-                fail && fail(FileError.NOT_FOUND_ERR);
-            }
-        );
-    },
-    
-    getDirectory:function(win,fail,args) {
-        var fullPath = args[0];
-        var path = args[1];
+        var fullPath = cordovaPathToNative(args[0]);
+        var path = cordovaPathToNative(args[1]);
         var options = args[2];
 
         var flag = "";
@@ -244,11 +228,7 @@ module.exports = {
             flag = new Flags(false, false);
         }
 
-        if (path !== null) {
-            path = path.replace("/", "\\");
-        }
-
-        Windows.Storage.StorageFolder.getFolderFromPathAsync(fullPath).then(
+        getFolderFromPathAsync(fullPath).then(
             function (storageFolder) {
                 if (flag.create === true && flag.exclusive === true) {
                     storageFolder.createFolderAsync(path, Windows.Storage.CreationCollisionOption.failIfExists).done(
@@ -261,7 +241,7 @@ module.exports = {
                 } else if (flag.create === true && flag.exclusive === false) {
                     storageFolder.createFolderAsync(path, Windows.Storage.CreationCollisionOption.openIfExists).done(
                         function (storageFolder) {
-                            win(new DirectoryEntry(storageFolder.name, storageFolder.path));
+                            win(new DirectoryEntry(storageFolder.name, storageFolder.path + "/"));
                         }, function () {
                             fail && fail(FileError.INVALID_MODIFICATION_ERR);
                         }
@@ -292,12 +272,13 @@ module.exports = {
         );
     },
 
-    remove:function(win,fail,args) {
-        var fullPath = args[0];
+    remove: function (win, fail, args) {
 
-        Windows.Storage.StorageFile.getFileFromPathAsync(fullPath).then(
+        var fullPath = cordovaPathToNative(args[0]);
+
+        getFileFromPathAsync(fullPath).then(
             function (sFile) {
-                Windows.Storage.StorageFile.getFileFromPathAsync(fullPath).done(function (storageFile) {
+                getFileFromPathAsync(fullPath).done(function (storageFile) {
                     storageFile.deleteAsync().done(win, function () {
                         fail && fail(FileError.INVALID_MODIFICATION_ERR);
 
@@ -305,12 +286,12 @@ module.exports = {
                 });
             },
             function () {
-                Windows.Storage.StorageFolder.getFolderFromPathAsync(fullPath).then(
+                getFolderFromPathAsync(fullPath).then(
                     function (sFolder) {
                         var removeEntry = function () {
                             var storageFolderTop = null;
 
-                            Windows.Storage.StorageFolder.getFolderFromPathAsync(fullPath).then(
+                            getFolderFromPathAsync(fullPath).then(
                                 function (storageFolder) {
                                     // FileSystem root can't be removed!
                                     var storageFolderPer = Windows.Storage.ApplicationData.current.localFolder;
@@ -358,12 +339,23 @@ module.exports = {
         );
     },
 
-    removeRecursively:function(successCallback,fail,args) {
-        var fullPath = args[0];
+    removeRecursively: function (successCallback, fail, args) {
 
-        Windows.Storage.StorageFolder.getFolderFromPathAsync(fullPath).done(function (storageFolder) {
-        var storageFolderPer = Windows.Storage.ApplicationData.current.localFolder;
-        var storageFolderTem = Windows.Storage.ApplicationData.current.temporaryFolder;
+        var fullPath = cordovaPathToNative(args[0]);
+
+        getFolderFromPathAsync(fullPath).done(function (storageFolder) {
+
+            storageFolder.deleteAsync().done(function (res) {
+                successCallback(res);
+            }, function (err) {
+                fail(err);
+            });
+
+            return;
+
+
+            var storageFolderPer = Windows.Storage.ApplicationData.current.localFoldser;
+            var storageFolderTem = Windows.Storage.ApplicationData.current.temporaryFolder;
 
         if (storageFolder.path == storageFolderPer.path || storageFolder.path == storageFolderTem.path) {
             fail && fail(FileError.NO_MODIFICATION_ALLOWED_ERR);
@@ -374,9 +366,11 @@ module.exports = {
             return new WinJS.Promise(function (complete) {
                 var filePromiseArr = [];
                 var storageFolderTop = null;
-                Windows.Storage.StorageFolder.getFolderFromPathAsync(path).then(
+                getFolderFromPathAsync(path).then(
                     function (storageFolder) {
-                        var fileListPromise = storageFolder.createFileQuery().getFilesAsync();
+                        var q = storageFolder.createFileQuery();
+
+                        var fileListPromise = q.getFilesAsync();
 
                         storageFolderTop = storageFolder;
                         return fileListPromise;
@@ -411,28 +405,31 @@ module.exports = {
             });
         };
         removeFolders(storageFolder.path).then(function () {
-            Windows.Storage.StorageFolder.getFolderFromPathAsync(storageFolder.path).then(
+            getFolderFromPathAsync(storageFolder.path).then(
                 function () {},
                 function () {
                     if (typeof successCallback !== 'undefined' && successCallback !== null) { successCallback(); }
                 });
             });
+        }, function (err) {
+
         });
     },
 
-    getFile:function(win,fail,args) {
-		//not sure why, but it won't work with normal slashes...
-		var fullPath = args[0].replace(/\//g, '\\');
-        var path = args[1].replace(/\//g, '\\');
+    getFile: function (win, fail, args) {
+
+        //not sure why, but it won't work with normal slashes...
+        var fullPath = cordovaPathToNative(args[0]);
+        var path = cordovaPathToNative(args[1]);
         var options = args[2];
 
         var completePath = fullPath + '\\' + path;
-		//handles trailing slash and leading slash, or just one or the other
+        //handles trailing slash and leading slash, or just one or the other
         completePath = completePath.replace(/\\\\\\/g, '/').replace(/\\\\/g, '\\');
 
         var fileName = completePath.substring(completePath.lastIndexOf('\\'));
-		
-		//final adjustment
+        
+        //final adjustment
         fullPath = completePath.substring(0, completePath.lastIndexOf('\\'));
         path = fileName.replace(/\\/g, '');
 
@@ -443,7 +440,7 @@ module.exports = {
             flag = new Flags(false, false);
         }
 
-        Windows.Storage.StorageFolder.getFolderFromPathAsync(fullPath).then(
+        getFolderFromPathAsync(fullPath).then(
             function (storageFolder) {
                 if (flag.create === true && flag.exclusive === true) {
                     storageFolder.createFileAsync(path, Windows.Storage.CreationCollisionOption.failIfExists).done(
@@ -486,12 +483,13 @@ module.exports = {
         );
     },
 
-    readEntries:function(win,fail,args) { // ["fullPath"]
-        var path = args[0];
+    readEntries: function (win, fail, args) { // ["fullPath"]
+
+        var path = cordovaPathToNative(args[0]);
 
         var result = [];
 
-        Windows.Storage.StorageFolder.getFolderFromPathAsync(path).then(function (storageFolder) {
+        getFolderFromPathAsync(path).then(function (storageFolder) {
             var promiseArr = [];
             var index = 0;
             promiseArr[index++] = storageFolder.createFileQuery().getFilesAsync().then(function (fileList) {
@@ -515,8 +513,9 @@ module.exports = {
         }, function () { fail && fail(FileError.NOT_FOUND_ERR); });
     },
 
-    write:function(win,fail,args) {
-        var fileName = args[0],
+    write: function (win, fail, args) {
+
+        var fileName = cordovaPathToNative(args[0]),
             data = args[1],
             position = args[2],
             isBinary = args[3];
@@ -536,7 +535,7 @@ module.exports = {
             file = fileName.split('\\').pop();
         
 
-        Windows.Storage.StorageFolder.getFolderFromPathAsync(path).done(
+        getFolderFromPathAsync(path).done(
             function(storageFolder) {
                 storageFolder.createFileAsync(file, Windows.Storage.CreationCollisionOption.openIfExists).done(
                     function(storageFile) {
@@ -556,11 +555,12 @@ module.exports = {
             });
     },
 
-    truncate:function(win,fail,args) { // ["fileName","size"]
-        var fileName = args[0];
+    truncate: function (win, fail, args) { // ["fileName","size"]
+
+        var fileName = cordovaPathToNative(args[0]);
         var size = args[1];
 
-        Windows.Storage.StorageFile.getFileFromPathAsync(fileName).done(function(storageFile){
+        getFileFromPathAsync(fileName).done(function(storageFile){
             //the current length of the file.
             var leng = 0;
 
@@ -580,7 +580,7 @@ module.exports = {
                         var successCallBack = function (entry) {
                             parentPath = entry.fullPath;
                             storageFile.deleteAsync().then(function () {
-                                return Windows.Storage.StorageFolder.getFolderFromPathAsync(parentPath);
+                                return getFolderFromPathAsync(parentPath);
                             }).then(function (storageFolder) {
                                 storageFolder.createFileAsync(name).then(function (newStorageFile) {
                                     Windows.Storage.FileIO.writeTextAsync(newStorageFile, fileContent).done(function () {
@@ -598,9 +598,10 @@ module.exports = {
         }, function () { fail && fail(FileError.NOT_FOUND_ERR); });
     },
 
-    copyTo:function(success,fail,args) { // ["fullPath","parent", "newName"]
-        var srcPath = args[0];
-        var parentFullPath = args[1];
+    copyTo: function (success, fail, args) { // ["fullPath","parent", "newName"]
+
+        var srcPath = cordovaPathToNative(args[0]);
+        var parentFullPath = cordovaPathToNative(args[1]);
         var name = args[2];
 
         //name can't be invalid
@@ -610,13 +611,13 @@ module.exports = {
         }
         // copy
         var copyFiles = "";
-        Windows.Storage.StorageFile.getFileFromPathAsync(srcPath).then(
+        getFileFromPathAsync(srcPath).then(
             function (sFile) {
                 copyFiles = function (srcPath, parentPath) {
                     var storageFileTop = null;
-                    Windows.Storage.StorageFile.getFileFromPathAsync(srcPath).then(function (storageFile) {
+                    getFileFromPathAsync(srcPath).then(function (storageFile) {
                         storageFileTop = storageFile;
-                        return Windows.Storage.StorageFolder.getFolderFromPathAsync(parentPath);
+                        return getFolderFromPathAsync(parentPath);
                     }, function () {
 
                         fail && fail(FileError.NOT_FOUND_ERR);
@@ -639,7 +640,7 @@ module.exports = {
                 copyFinish(srcPath, parentFullPath);
             },
             function () {
-                Windows.Storage.StorageFolder.getFolderFromPathAsync(srcPath).then(
+                getFolderFromPathAsync(srcPath).then(
                     function (sFolder) {
                         copyFiles = function (srcPath, parentPath) {
                             var coreCopy = function (storageFolderTop, complete) {
@@ -647,7 +648,7 @@ module.exports = {
                                     var folderPromiseArr = [];
                                     if (folderList.length === 0) { complete(); }
                                     else {
-                                        Windows.Storage.StorageFolder.getFolderFromPathAsync(parentPath).then(function (storageFolderTarget) {
+                                        getFolderFromPathAsync(parentPath).then(function (storageFolderTarget) {
                                             var tempPromiseArr = [];
                                             var index = 0;
                                             for (var j = 0; j < folderList.length; j++) {
@@ -667,13 +668,13 @@ module.exports = {
                                 var storageFolderTop = null;
                                 var filePromiseArr = [];
                                 var fileListTop = null;
-                                Windows.Storage.StorageFolder.getFolderFromPathAsync(srcPath).then(function (storageFolder) {
+                                getFolderFromPathAsync(srcPath).then(function (storageFolder) {
                                     storageFolderTop = storageFolder;
                                     return storageFolder.createFileQuery().getFilesAsync();
                                 }).then(function (fileList) {
                                     fileListTop = fileList;
                                     if (fileList) {
-                                        return Windows.Storage.StorageFolder.getFolderFromPathAsync(parentPath);
+                                        return getFolderFromPathAsync(parentPath);
                                     }
                                 }).then(function (targetStorageFolder) {
                                     for (var i = 0; i < fileListTop.length; i++) {
@@ -688,7 +689,7 @@ module.exports = {
                             });
                         };
                         var copyFinish = function (srcPath, parentPath) {
-                            Windows.Storage.StorageFolder.getFolderFromPathAsync(parentPath).then(function (storageFolder) {
+                            getFolderFromPathAsync(parentPath).then(function (storageFolder) {
                                 storageFolder.createFolderAsync(name, Windows.Storage.CreationCollisionOption.openIfExists).then(function (newStorageFolder) {
                                     //can't copy onto itself
                                     if (srcPath == newStorageFolder.path) {
@@ -701,7 +702,7 @@ module.exports = {
                                         return;
                                     }
                                     copyFiles(srcPath, newStorageFolder.path).then(function () {
-                                        Windows.Storage.StorageFolder.getFolderFromPathAsync(newStorageFolder.path).done(
+                                        getFolderFromPathAsync(newStorageFolder.path).done(
                                             function (storageFolder) {
                                                 success(new DirectoryEntry(storageFolder.name, storageFolder.path));
                                             },
@@ -720,9 +721,10 @@ module.exports = {
         );
     },
 
-    moveTo:function(success,fail,args) {
-        var srcPath = args[0];
-        var parentFullPath = args[1];
+    moveTo: function (success, fail, args) {
+
+        var srcPath = cordovaPathToNative(args[0]);
+        var parentFullPath = cordovaPathToNative(args[1]);
         var name = args[2];
 
 
@@ -733,13 +735,13 @@ module.exports = {
         }
 
         var moveFiles = "";
-        Windows.Storage.StorageFile.getFileFromPathAsync(srcPath).then(
+        getFileFromPathAsync(srcPath).then(
             function (sFile) {
                 moveFiles = function (srcPath, parentPath) {
                     var storageFileTop = null;
-                    Windows.Storage.StorageFile.getFileFromPathAsync(srcPath).then(function (storageFile) {
+                    getFileFromPathAsync(srcPath).then(function (storageFile) {
                         storageFileTop = storageFile;
-                        return Windows.Storage.StorageFolder.getFolderFromPathAsync(parentPath);
+                        return getFolderFromPathAsync(parentPath);
                     }, function () {
                         fail && fail(FileError.NOT_FOUND_ERR);
                     }).then(function (storageFolder) {
@@ -763,7 +765,7 @@ module.exports = {
                 moveFinish(srcPath, parentFullPath);
             },
             function () {
-                Windows.Storage.StorageFolder.getFolderFromPathAsync(srcPath).then(
+                getFolderFromPathAsync(srcPath).then(
                     function (sFolder) {
                         moveFiles = function (srcPath, parentPath) {
                             var coreMove = function (storageFolderTop, complete) {
@@ -774,7 +776,7 @@ module.exports = {
                                         complete();
                                     }
                                     else {
-                                        Windows.Storage.StorageFolder.getFolderFromPathAsync(parentPath).then(function (storageFolderTarget) {
+                                        getFolderFromPathAsync(parentPath).then(function (storageFolderTarget) {
                                             var tempPromiseArr = [];
                                             var index = 0;
                                             for (var j = 0; j < folderList.length; j++) {
@@ -791,12 +793,12 @@ module.exports = {
                             };
                             return new WinJS.Promise(function (complete) {
                                 var storageFolderTop = null;
-                                Windows.Storage.StorageFolder.getFolderFromPathAsync(srcPath).then(function (storageFolder) {
+                                getFolderFromPathAsync(srcPath).then(function (storageFolder) {
                                     storageFolderTop = storageFolder;
                                     return storageFolder.createFileQuery().getFilesAsync();
                                 }).then(function (fileList) {
                                     var filePromiseArr = [];
-                                    Windows.Storage.StorageFolder.getFolderFromPathAsync(parentPath).then(function (dstStorageFolder) {
+                                    getFolderFromPathAsync(parentPath).then(function (dstStorageFolder) {
                                         if (fileList) {
                                             for (var i = 0; i < fileList.length; i++) {
                                                 filePromiseArr.push(fileList[i].moveAsync(dstStorageFolder));
@@ -811,9 +813,9 @@ module.exports = {
                         };
                         var moveFinish = function (srcPath, parentPath) {
                             var originFolderTop = null;
-                            Windows.Storage.StorageFolder.getFolderFromPathAsync(srcPath).then(function (originFolder) {
+                            getFolderFromPathAsync(srcPath).then(function (originFolder) {
                                 originFolderTop = originFolder;
-                                return Windows.Storage.StorageFolder.getFolderFromPathAsync(parentPath);
+                                return getFolderFromPathAsync(parentPath);
                             }, function () {
                                 fail && fail(FileError.INVALID_MODIFICATION_ERR);
                             }).then(function (storageFolder) {
@@ -862,7 +864,8 @@ module.exports = {
 
     persistentFileSystem:null,
 
-    requestFileSystem:function(win,fail,args) {
+    requestFileSystem: function (win, fail, args) {
+
         var type = args[0];
         var size = args[1];
 
@@ -892,8 +895,9 @@ module.exports = {
         win(result);
     },
 
-    resolveLocalFileSystemURI:function(success,fail,args) {
-        var uri = args[0];
+    resolveLocalFileSystemURI: function (success, fail, args) {
+
+        var uri = cordovaPathToNative(args[0]);
 
         var path = uri;
 
@@ -918,17 +922,14 @@ module.exports = {
                 return;
             }
         }
-        
-        // refine path format to make sure it is correct
-        path = path.split("/").join("\\");
 
-        Windows.Storage.StorageFile.getFileFromPathAsync(path).then(
+        getFileFromPathAsync(path).then(
             function (storageFile) {
                 success(new FileEntry(storageFile.name, storageFile.path));
             }, function () {
-                Windows.Storage.StorageFolder.getFolderFromPathAsync(path).then(
+                getFolderFromPathAsync(path).then(
                     function (storageFolder) {
-                        success(new DirectoryEntry(storageFolder.name, storageFolder.path));
+                        success(new DirectoryEntry(storageFolder.name, storageFolder.path + "/", null, storageFolder.path + "/"));
                     }, function () {
                         fail && fail(FileError.NOT_FOUND_ERR);
                     }
@@ -939,5 +940,3 @@ module.exports = {
     
 
 };
-
-require("cordova/exec/proxy").add("File",module.exports);


[4/7] git commit: re-apply readAsBinaryString and readAsArrayBuffer

Posted by pu...@apache.org.
re-apply readAsBinaryString and readAsArrayBuffer


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/commit/0788b708
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/tree/0788b708
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/diff/0788b708

Branch: refs/heads/master
Commit: 0788b708de23c08ab56a34f05d7acd8773feb998
Parents: 44b2a07
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Tue Jul 8 18:06:40 2014 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Tue Jul 8 18:06:40 2014 -0700

----------------------------------------------------------------------
 src/windows8/FileProxy.js | 40 +++++++++++++++++++++++++++++++++++++++-
 1 file changed, 39 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/0788b708/src/windows8/FileProxy.js
----------------------------------------------------------------------
diff --git a/src/windows8/FileProxy.js b/src/windows8/FileProxy.js
index 0c722d1..b8830ab 100644
--- a/src/windows8/FileProxy.js
+++ b/src/windows8/FileProxy.js
@@ -190,11 +190,49 @@ module.exports = {
             });
     },
 
+    readAsBinaryString:function(win,fail,args) {
+        var fileName = cordovaPathToNative((args[0]);
+
+        getFileFromPathAsync(fileName).then(
+            function (storageFile) {
+                Windows.Storage.FileIO.readBufferAsync(storageFile).done(
+                    function (buffer) {
+                        var dataReader = Windows.Storage.Streams.DataReader.fromBuffer(buffer);
+                        var fileContent = dataReader.readString(buffer.length);
+                        dataReader.close();
+                        win(fileContent);
+                    }
+                );
+            }, function () {
+                fail && fail(FileError.NOT_FOUND_ERR);
+            }
+        );
+    },
+
+    readAsArrayBuffer:function(win,fail,args) {
+        var fileName =cordovaPathToNative(args[0]);
+
+        getFileFromPathAsync(fileName).then(
+            function (storageFile) {
+                var blob = MSApp.createFileFromStorageFile(storageFile);
+                var url = URL.createObjectURL(blob, { oneTimeOnly: true });
+                var xhr = new XMLHttpRequest();
+                xhr.open("GET", url, true);
+                xhr.responseType = 'arraybuffer';
+                xhr.onload = function() {
+                    win(xhr.response);
+                };
+                xhr.send();
+            }, function () {
+                fail && fail(FileError.NOT_FOUND_ERR);
+            }
+        );
+    },
+
     readAsDataURL: function (win, fail, args) {
 
         var fileName = cordovaPathToNative(args[0]);
 
-
         getFileFromPathAsync(fileName).then(
             function (storageFile) {
                 Windows.Storage.FileIO.readBufferAsync(storageFile).done(


[7/7] git commit: remove extra function closure, not needed

Posted by pu...@apache.org.
remove extra function closure, not needed


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/commit/cc833d17
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/tree/cc833d17
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/diff/cc833d17

Branch: refs/heads/master
Commit: cc833d17c1e7d38532bc4311f7b5948cc0d44886
Parents: d678c78
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Tue Jul 8 18:53:42 2014 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Tue Jul 8 18:53:42 2014 -0700

----------------------------------------------------------------------
 src/windows8/FileProxy.js | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/cc833d17/src/windows8/FileProxy.js
----------------------------------------------------------------------
diff --git a/src/windows8/FileProxy.js b/src/windows8/FileProxy.js
index 93fdc8e..0412d93 100644
--- a/src/windows8/FileProxy.js
+++ b/src/windows8/FileProxy.js
@@ -43,13 +43,8 @@ function nativePathToCordova(path) {
     return cleanPath;
 };
 
-function getFolderFromPathAsync(path) {
-    return Windows.Storage.StorageFolder.getFolderFromPathAsync(path);
-};
-
-function getFileFromPathAsync(path) {
-    return Windows.Storage.StorageFile.getFileFromPathAsync(path);
-};
+var getFolderFromPathAsync = Windows.Storage.StorageFolder.getFolderFromPathAsync;
+var getFileFromPathAsync = Windows.Storage.StorageFile.getFileFromPathAsync;
 
 
 module.exports = {


[2/7] git commit: fix typo

Posted by pu...@apache.org.
fix typo


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/commit/39d6d463
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/tree/39d6d463
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/diff/39d6d463

Branch: refs/heads/master
Commit: 39d6d463eccdf5d73f88468f76989ef4ffb99b32
Parents: ba142db
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Tue Jul 8 15:41:37 2014 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Tue Jul 8 17:02:44 2014 -0700

----------------------------------------------------------------------
 src/windows8/FileProxy.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/39d6d463/src/windows8/FileProxy.js
----------------------------------------------------------------------
diff --git a/src/windows8/FileProxy.js b/src/windows8/FileProxy.js
index d4ff33f..e9fc0db 100644
--- a/src/windows8/FileProxy.js
+++ b/src/windows8/FileProxy.js
@@ -354,7 +354,7 @@ module.exports = {
             return;
 
 
-            var storageFolderPer = Windows.Storage.ApplicationData.current.localFoldser;
+            var storageFolderPer = Windows.Storage.ApplicationData.current.localFolder;
             var storageFolderTem = Windows.Storage.ApplicationData.current.temporaryFolder;
 
         if (storageFolder.path == storageFolderPer.path || storageFolder.path == storageFolderTem.path) {


[5/7] git commit: remove check for undefined fail(), it is defined by the proxy and always exists

Posted by pu...@apache.org.
remove check for undefined fail(), it is defined by the proxy and always exists


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/commit/edc422f6
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/tree/edc422f6
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/diff/edc422f6

Branch: refs/heads/master
Commit: edc422f65a569cf5fc10f648ce63221526135a52
Parents: 0788b70
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Tue Jul 8 18:11:18 2014 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Tue Jul 8 18:11:18 2014 -0700

----------------------------------------------------------------------
 src/windows8/FileProxy.js | 130 ++++++++++++++++++++---------------------
 1 file changed, 65 insertions(+), 65 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/edc422f6/src/windows8/FileProxy.js
----------------------------------------------------------------------
diff --git a/src/windows8/FileProxy.js b/src/windows8/FileProxy.js
index b8830ab..bd77725 100644
--- a/src/windows8/FileProxy.js
+++ b/src/windows8/FileProxy.js
@@ -64,11 +64,11 @@ module.exports = {
                     function (basicProperties) {
                         win(new File(storageFile.name, storageFile.path, storageFile.fileType, basicProperties.dateModified, basicProperties.size));
                     }, function () {
-                        fail && fail(FileError.NOT_READABLE_ERR);
+                        fail(FileError.NOT_READABLE_ERR);
                     }
                 );
             }, function () {
-                fail && fail(FileError.NOT_FOUND_ERR);
+                fail(FileError.NOT_FOUND_ERR);
             }
         );
     },
@@ -83,7 +83,7 @@ module.exports = {
                     return storageFile.getBasicPropertiesAsync();
                 },
                 function () {
-                    fail && fail(FileError.NOT_READABLE_ERR);
+                    fail(FileError.NOT_READABLE_ERR);
                 }
             // get the basic properties of the file.
             ).then(
@@ -91,7 +91,7 @@ module.exports = {
                     success(basicProperties.dateModified);
                 },
                 function () {
-                    fail && fail(FileError.NOT_READABLE_ERR);
+                    fail(FileError.NOT_READABLE_ERR);
                 }
             );
         };
@@ -102,7 +102,7 @@ module.exports = {
                     return storageFolder.getBasicPropertiesAsync();
                 },
                 function () {
-                    fail && fail(FileError.NOT_READABLE_ERR);
+                    fail(FileError.NOT_READABLE_ERR);
                 }
             // get the basic properties of the folder.
             ).then(
@@ -110,7 +110,7 @@ module.exports = {
                     success(basicProperties.dateModified);
                 },
                 function () {
-                    fail && fail(FileError.NOT_FOUND_ERR);
+                    fail(FileError.NOT_FOUND_ERR);
                 }
             );
         };
@@ -126,7 +126,7 @@ module.exports = {
                     function (sFolder) {
                         dealFolder(sFolder);
                     }, function () {
-                        fail && fail(FileError.NOT_FOUND_ERR);
+                        fail(FileError.NOT_FOUND_ERR);
                     }
                 );
             }
@@ -154,7 +154,7 @@ module.exports = {
         var result = new DirectoryEntry(popItem, fullPath.substr(0, fullPath.length - popItem.length - 1));
         getFolderFromPathAsync(result.fullPath).done(
             function () { win(result); },
-            function () { fail && fail(FileError.INVALID_STATE_ERR); }
+            function () { fail(FileError.INVALID_STATE_ERR); }
         );
     },
 
@@ -186,7 +186,7 @@ module.exports = {
             }).done(function(buffer) {
                 win(Windows.Security.Cryptography.CryptographicBuffer.convertBinaryToString(encoding, buffer));
             },function() {
-                fail && fail(FileError.NOT_FOUND_ERR);
+                fail(FileError.NOT_FOUND_ERR);
             });
     },
 
@@ -204,7 +204,7 @@ module.exports = {
                     }
                 );
             }, function () {
-                fail && fail(FileError.NOT_FOUND_ERR);
+                fail(FileError.NOT_FOUND_ERR);
             }
         );
     },
@@ -224,7 +224,7 @@ module.exports = {
                 };
                 xhr.send();
             }, function () {
-                fail && fail(FileError.NOT_FOUND_ERR);
+                fail(FileError.NOT_FOUND_ERR);
             }
         );
     },
@@ -248,7 +248,7 @@ module.exports = {
                     }
                 );
             }, function () {
-                fail && fail(FileError.NOT_FOUND_ERR);
+                fail(FileError.NOT_FOUND_ERR);
             }
         );
     },
@@ -273,7 +273,7 @@ module.exports = {
                         function (storageFolder) {
                             win(new DirectoryEntry(storageFolder.name, storageFolder.path));
                         }, function () {
-                            fail && fail(FileError.PATH_EXISTS_ERR);
+                            fail(FileError.PATH_EXISTS_ERR);
                         }
                     );
                 } else if (flag.create === true && flag.exclusive === false) {
@@ -281,12 +281,12 @@ module.exports = {
                         function (storageFolder) {
                             win(new DirectoryEntry(storageFolder.name, storageFolder.path + "/"));
                         }, function () {
-                            fail && fail(FileError.INVALID_MODIFICATION_ERR);
+                            fail(FileError.INVALID_MODIFICATION_ERR);
                         }
                     );
                 } else if (flag.create === false) {
                     if (/\?|\\|\*|\||\"|<|>|\:|\//g.test(path)) {
-                        fail && fail(FileError.ENCODING_ERR);
+                        fail(FileError.ENCODING_ERR);
                         return;
                     }
 
@@ -297,15 +297,15 @@ module.exports = {
                             // check if path actually points to a file
                             storageFolder.getFileAsync(path).done(
                                 function () {
-                                    fail && fail(FileError.TYPE_MISMATCH_ERR);
+                                    fail(FileError.TYPE_MISMATCH_ERR);
                                 }, function() {
-                                    fail && fail(FileError.NOT_FOUND_ERR);
+                                    fail(FileError.NOT_FOUND_ERR);
                                 });
                         }
                     );
                 }
             }, function () {
-                fail && fail(FileError.NOT_FOUND_ERR);
+                fail(FileError.NOT_FOUND_ERR);
             }
         );
     },
@@ -318,7 +318,7 @@ module.exports = {
             function (sFile) {
                 getFileFromPathAsync(fullPath).done(function (storageFile) {
                     storageFile.deleteAsync().done(win, function () {
-                        fail && fail(FileError.INVALID_MODIFICATION_ERR);
+                        fail(FileError.INVALID_MODIFICATION_ERR);
 
                     });
                 });
@@ -335,13 +335,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 && fail(FileError.NO_MODIFICATION_ALLOWED_ERR);
+                                        fail(FileError.NO_MODIFICATION_ALLOWED_ERR);
                                         return;
                                     }
                                     storageFolderTop = storageFolder;
                                     return storageFolder.createFileQuery().getFilesAsync();
                                 }, function () {
-                                    fail && fail(FileError.INVALID_MODIFICATION_ERR);
+                                    fail(FileError.INVALID_MODIFICATION_ERR);
 
                                 }
                             // check sub-files.
@@ -350,7 +350,7 @@ module.exports = {
                                     if (fileList.length === 0) {
                                         return storageFolderTop.createFolderQuery().getFoldersAsync();
                                     } else {
-                                        fail && fail(FileError.INVALID_MODIFICATION_ERR);
+                                        fail(FileError.INVALID_MODIFICATION_ERR);
                                     }
                                 }
                             // check sub-folders.
@@ -358,11 +358,11 @@ module.exports = {
                                 if (folderList) {
                                     if (folderList.length === 0) {
                                         storageFolderTop.deleteAsync().done(win, function () {
-                                            fail && fail(FileError.INVALID_MODIFICATION_ERR);
+                                            fail(FileError.INVALID_MODIFICATION_ERR);
 
                                         });
                                     } else {
-                                        fail && fail(FileError.INVALID_MODIFICATION_ERR);
+                                        fail(FileError.INVALID_MODIFICATION_ERR);
                                     }
                                 }
 
@@ -370,7 +370,7 @@ module.exports = {
                         };
                         removeEntry();
                     }, function () {
-                        fail && fail(FileError.NOT_FOUND_ERR);
+                        fail(FileError.NOT_FOUND_ERR);
                     }
                 );
             }
@@ -396,7 +396,7 @@ module.exports = {
             var storageFolderTem = Windows.Storage.ApplicationData.current.temporaryFolder;
 
         if (storageFolder.path == storageFolderPer.path || storageFolder.path == storageFolderTem.path) {
-            fail && fail(FileError.NO_MODIFICATION_ALLOWED_ERR);
+            fail(FileError.NO_MODIFICATION_ALLOWED_ERR);
             return;
         }
 
@@ -485,7 +485,7 @@ module.exports = {
                         function (storageFile) {
                             win(new FileEntry(storageFile.name, storageFile.path));
                         }, function () {
-                            fail && fail(FileError.PATH_EXISTS_ERR);
+                            fail(FileError.PATH_EXISTS_ERR);
                         }
                     );
                 } else if (flag.create === true && flag.exclusive === false) {
@@ -493,12 +493,12 @@ module.exports = {
                         function (storageFile) {
                             win(new FileEntry(storageFile.name, storageFile.path));
                         }, function () {
-                            fail && fail(FileError.INVALID_MODIFICATION_ERR);
+                            fail(FileError.INVALID_MODIFICATION_ERR);
                         }
                     );
                 } else if (flag.create === false) {
                     if (/\?|\\|\*|\||\"|<|>|\:|\//g.test(path)) {
-                        fail && fail(FileError.ENCODING_ERR);
+                        fail(FileError.ENCODING_ERR);
                         return;
                     }
                     storageFolder.getFileAsync(path).done(
@@ -508,15 +508,15 @@ module.exports = {
                             // check if path actually points to a folder
                             storageFolder.getFolderAsync(path).done(
                                 function () {
-                                    fail && fail(FileError.TYPE_MISMATCH_ERR);
+                                    fail(FileError.TYPE_MISMATCH_ERR);
                                 }, function () {
-                                    fail && fail(FileError.NOT_FOUND_ERR);
+                                    fail(FileError.NOT_FOUND_ERR);
                                 });
                         }
                     );
                 }
             }, function () {
-                fail && fail(FileError.NOT_FOUND_ERR);
+                fail(FileError.NOT_FOUND_ERR);
             }
         );
     },
@@ -548,7 +548,7 @@ module.exports = {
                 win(result);
             });
 
-        }, function () { fail && fail(FileError.NOT_FOUND_ERR); });
+        }, function () { fail(FileError.NOT_FOUND_ERR); });
     },
 
     write: function (win, fail, args) {
@@ -581,15 +581,15 @@ module.exports = {
                             done(function () {
                                 win(data.length);
                             }, function () {
-                                fail && fail(FileError.INVALID_MODIFICATION_ERR);
+                                fail(FileError.INVALID_MODIFICATION_ERR);
                             });
                     }, function() {
-                        fail && fail(FileError.INVALID_MODIFICATION_ERR);
+                        fail(FileError.INVALID_MODIFICATION_ERR);
                     }
                 );
                 
             }, function() {
-                fail && fail(FileError.NOT_FOUND_ERR);
+                fail(FileError.NOT_FOUND_ERR);
             });
     },
 
@@ -624,16 +624,16 @@ module.exports = {
                                     Windows.Storage.FileIO.writeTextAsync(newStorageFile, fileContent).done(function () {
                                         win(String(fileContent).length);
                                     }, function () {
-                                        fail && fail(FileError.NO_MODIFICATION_ALLOWED_ERR);
+                                        fail(FileError.NO_MODIFICATION_ALLOWED_ERR);
                                     });
                                 });
                             });
                         };
                         entry.getParent(successCallBack, null);
-                    }, function () { fail && fail(FileError.NOT_FOUND_ERR); });
+                    }, function () { fail(FileError.NOT_FOUND_ERR); });
                 }
             });
-        }, function () { fail && fail(FileError.NOT_FOUND_ERR); });
+        }, function () { fail(FileError.NOT_FOUND_ERR); });
     },
 
     copyTo: function (success, fail, args) { // ["fullPath","parent", "newName"]
@@ -644,7 +644,7 @@ module.exports = {
 
         //name can't be invalid
         if (/\?|\\|\*|\||\"|<|>|\:|\//g.test(name)) {
-            fail && fail(FileError.ENCODING_ERR);
+            fail(FileError.ENCODING_ERR);
             return;
         }
         // copy
@@ -658,18 +658,18 @@ module.exports = {
                         return getFolderFromPathAsync(parentPath);
                     }, function () {
 
-                        fail && fail(FileError.NOT_FOUND_ERR);
+                        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 && fail(FileError.INVALID_MODIFICATION_ERR);
+                            fail(FileError.INVALID_MODIFICATION_ERR);
                         });
                     }, function () {
 
-                        fail && fail(FileError.NOT_FOUND_ERR);
+                        fail(FileError.NOT_FOUND_ERR);
                     });
                 };
                 var copyFinish = function (srcPath, parentPath) {
@@ -721,7 +721,7 @@ module.exports = {
                                     WinJS.Promise.join(filePromiseArr).done(function () {
                                         coreCopy(storageFolderTop, complete);
                                     }, function() {
-                                        fail && fail(FileError.INVALID_MODIFICATION_ERR);
+                                        fail(FileError.INVALID_MODIFICATION_ERR);
                                     });
                                 });
                             });
@@ -731,12 +731,12 @@ module.exports = {
                                 storageFolder.createFolderAsync(name, Windows.Storage.CreationCollisionOption.openIfExists).then(function (newStorageFolder) {
                                     //can't copy onto itself
                                     if (srcPath == newStorageFolder.path) {
-                                        fail && fail(FileError.INVALID_MODIFICATION_ERR);
+                                        fail(FileError.INVALID_MODIFICATION_ERR);
                                         return;
                                     }
                                     //can't copy into itself
                                     if (srcPath == parentPath) {
-                                        fail && fail(FileError.INVALID_MODIFICATION_ERR);
+                                        fail(FileError.INVALID_MODIFICATION_ERR);
                                         return;
                                     }
                                     copyFiles(srcPath, newStorageFolder.path).then(function () {
@@ -744,15 +744,15 @@ module.exports = {
                                             function (storageFolder) {
                                                 success(new DirectoryEntry(storageFolder.name, storageFolder.path));
                                             },
-                                            function () { fail && fail(FileError.NOT_FOUND_ERR); }
+                                            function () { fail(FileError.NOT_FOUND_ERR); }
                                         );
                                     });
-                                }, function () { fail && fail(FileError.INVALID_MODIFICATION_ERR); });
-                            }, function () { fail && fail(FileError.INVALID_MODIFICATION_ERR); });
+                                }, function () { fail(FileError.INVALID_MODIFICATION_ERR); });
+                            }, function () { fail(FileError.INVALID_MODIFICATION_ERR); });
                         };
                         copyFinish(srcPath, parentFullPath);
                     }, function () {
-                        fail && fail(FileError.NOT_FOUND_ERR);
+                        fail(FileError.NOT_FOUND_ERR);
                     }
                 );
             }
@@ -768,7 +768,7 @@ module.exports = {
 
         //name can't be invalid
         if (/\?|\\|\*|\||\"|<|>|\:|\//g.test(name)) {
-            fail && fail(FileError.ENCODING_ERR);
+            fail(FileError.ENCODING_ERR);
             return;
         }
 
@@ -781,21 +781,21 @@ module.exports = {
                         storageFileTop = storageFile;
                         return getFolderFromPathAsync(parentPath);
                     }, function () {
-                        fail && fail(FileError.NOT_FOUND_ERR);
+                        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 && fail(FileError.INVALID_MODIFICATION_ERR);
+                            fail(FileError.INVALID_MODIFICATION_ERR);
                         });
                     }, function () {
-                        fail && fail(FileError.NOT_FOUND_ERR);
+                        fail(FileError.NOT_FOUND_ERR);
                     });
                 };
                 var moveFinish = function (srcPath, parentPath) {
                     //can't copy onto itself
                     if (srcPath == parentPath + "\\" + name) {
-                        fail && fail(FileError.INVALID_MODIFICATION_ERR);
+                        fail(FileError.INVALID_MODIFICATION_ERR);
                         return;
                     }
                     moveFiles(srcPath, parentFullPath);
@@ -855,27 +855,27 @@ module.exports = {
                                 originFolderTop = originFolder;
                                 return getFolderFromPathAsync(parentPath);
                             }, function () {
-                                fail && fail(FileError.INVALID_MODIFICATION_ERR);
+                                fail(FileError.INVALID_MODIFICATION_ERR);
                             }).then(function (storageFolder) {
                                 return storageFolder.createFolderAsync(name, Windows.Storage.CreationCollisionOption.openIfExists);
                             }, function () {
-                                fail && fail(FileError.INVALID_MODIFICATION_ERR);
+                                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 && fail(FileError.INVALID_MODIFICATION_ERR);
+                                            fail(FileError.INVALID_MODIFICATION_ERR);
                                             return;
                                         }
                                         //can't copy onto itself
                                         if (srcPath == newStorageFolder.path) {
-                                            fail && fail(FileError.INVALID_MODIFICATION_ERR);
+                                            fail(FileError.INVALID_MODIFICATION_ERR);
                                             return;
                                         }
                                         //can't copy into itself
                                         if (srcPath == parentPath) {
-                                            fail && fail(FileError.INVALID_MODIFICATION_ERR);
+                                            fail(FileError.INVALID_MODIFICATION_ERR);
                                             return;
                                         }
                                         moveFiles(srcPath, newStorageFolder.path).then(function () {
@@ -887,12 +887,12 @@ module.exports = {
                                         }, function () { console.log("error!"); });
                                     });
                                 });
-                            }, function () { fail && fail(FileError.INVALID_MODIFICATION_ERR); });
+                            }, function () { fail(FileError.INVALID_MODIFICATION_ERR); });
 
                         };
                         moveFinish(srcPath, parentFullPath);
                     }, function () {
-                        fail && fail(FileError.NOT_FOUND_ERR);
+                        fail(FileError.NOT_FOUND_ERR);
                     }
                 );
             }
@@ -924,7 +924,7 @@ module.exports = {
 
         var MAX_SIZE = 10000000000;
         if (size > MAX_SIZE) {
-            fail && fail(FileError.QUOTA_EXCEEDED_ERR);
+            fail(FileError.QUOTA_EXCEEDED_ERR);
             return;
         }
 
@@ -956,7 +956,7 @@ module.exports = {
             // method should not let read files outside of the [APP HASH]/Local or [APP HASH]/temp folders
             if (path.indexOf(Windows.Storage.ApplicationData.current.temporaryFolder.path) != 0 &&
                 path.indexOf(Windows.Storage.ApplicationData.current.localFolder.path) != 0) {
-                fail && fail(FileError.ENCODING_ERR);
+                fail(FileError.ENCODING_ERR);
                 return;
             }
         }
@@ -969,7 +969,7 @@ module.exports = {
                     function (storageFolder) {
                         success(new DirectoryEntry(storageFolder.name, storageFolder.path + "/", null, storageFolder.path + "/"));
                     }, function () {
-                        fail && fail(FileError.NOT_FOUND_ERR);
+                        fail(FileError.NOT_FOUND_ERR);
                     }
                 );
             }


[6/7] git commit: typo-negative

Posted by pu...@apache.org.
typo-negative


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/commit/d678c781
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/tree/d678c781
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/diff/d678c781

Branch: refs/heads/master
Commit: d678c7819a4c3479b495ce86176383e80ffee138
Parents: edc422f
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Tue Jul 8 18:16:50 2014 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Tue Jul 8 18:16:50 2014 -0700

----------------------------------------------------------------------
 src/windows8/FileProxy.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/d678c781/src/windows8/FileProxy.js
----------------------------------------------------------------------
diff --git a/src/windows8/FileProxy.js b/src/windows8/FileProxy.js
index bd77725..93fdc8e 100644
--- a/src/windows8/FileProxy.js
+++ b/src/windows8/FileProxy.js
@@ -191,7 +191,7 @@ module.exports = {
     },
 
     readAsBinaryString:function(win,fail,args) {
-        var fileName = cordovaPathToNative((args[0]);
+        var fileName = cordovaPathToNative(args[0]);
 
         getFileFromPathAsync(fileName).then(
             function (storageFile) {


[3/7] git commit: Oops, need the proxy call.

Posted by pu...@apache.org.
Oops, need the proxy call.


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/commit/44b2a075
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/tree/44b2a075
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/diff/44b2a075

Branch: refs/heads/master
Commit: 44b2a07533f0980a2c35764d5916698302b140fd
Parents: 39d6d46
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Tue Jul 8 17:50:51 2014 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Tue Jul 8 17:50:51 2014 -0700

----------------------------------------------------------------------
 src/windows8/FileProxy.js | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/44b2a075/src/windows8/FileProxy.js
----------------------------------------------------------------------
diff --git a/src/windows8/FileProxy.js b/src/windows8/FileProxy.js
index e9fc0db..0c722d1 100644
--- a/src/windows8/FileProxy.js
+++ b/src/windows8/FileProxy.js
@@ -940,3 +940,5 @@ module.exports = {
     
 
 };
+
+require("cordova/exec/proxy").add("File",module.exports);