incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From purplecabb...@apache.org
Subject [38/45] js commit: Added/removed semicolons
Date Sat, 06 Oct 2012 09:19:21 GMT
Added/removed semicolons


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

Branch: refs/heads/master
Commit: ecf6273350fac76be05b1e9196a08ed9bbbda46f
Parents: a1c3b6f
Author: mpberk <matthew.p.berk@intel.com>
Authored: Thu Aug 30 10:49:16 2012 -0700
Committer: mpberk <matthew.p.berk@intel.com>
Committed: Thu Aug 30 10:49:16 2012 -0700

----------------------------------------------------------------------
 lib/windows8/plugin/windows8/AccelerometerProxy.js |    3 +-
 lib/windows8/plugin/windows8/CameraProxy.js        |   82 +-
 lib/windows8/plugin/windows8/FileProxy.js          | 1222 +++++++-------
 lib/windows8/plugin/windows8/FileTransferProxy.js  |   42 +-
 lib/windows8/plugin/windows8/MediaFile.js          |   14 +-
 lib/windows8/plugin/windows8/MediaProxy.js         |    8 +-
 lib/windows8/plugin/windows8/NotificationProxy.js  |    5 +-
 lib/windows8/plugin/windows8/geolocation.js        |    4 +-
 8 files changed, 686 insertions(+), 694 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/ecf62733/lib/windows8/plugin/windows8/AccelerometerProxy.js
----------------------------------------------------------------------
diff --git a/lib/windows8/plugin/windows8/AccelerometerProxy.js b/lib/windows8/plugin/windows8/AccelerometerProxy.js
index 84199df..46749b5 100644
--- a/lib/windows8/plugin/windows8/AccelerometerProxy.js
+++ b/lib/windows8/plugin/windows8/AccelerometerProxy.js
@@ -1,6 +1,5 @@
 /*global Windows:true */
-var cordova = require('cordova'),
-    Acceleration = require('cordova/plugin/Acceleration');
+var Acceleration = require('cordova/plugin/Acceleration');
 
 /* This is the actual implementation part that returns the result on Windows 8
 */

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/ecf62733/lib/windows8/plugin/windows8/CameraProxy.js
----------------------------------------------------------------------
diff --git a/lib/windows8/plugin/windows8/CameraProxy.js b/lib/windows8/plugin/windows8/CameraProxy.js
index f4c91c3..2e62ed9 100644
--- a/lib/windows8/plugin/windows8/CameraProxy.js
+++ b/lib/windows8/plugin/windows8/CameraProxy.js
@@ -2,7 +2,8 @@
 
 
 var cordova = require('cordova'),
-    Camera = require('cordova/plugin/CameraConstants');
+    Camera = require('cordova/plugin/CameraConstants'),
+    FileEntry = require('cordova/plugin/FileEntry');
 
 
 module.exports = {
@@ -45,8 +46,7 @@ module.exports = {
             var imgObj = new Image();
             var success = function (fileEntry) {
                 var successCB = function (filePhoto) {
-                    var filePhoto = filePhoto,
-                        fileType = file.contentType,
+                    var fileType = file.contentType,
                         reader = new FileReader();
                     reader.onloadend = function () {
                         var image = new Image();
@@ -71,26 +71,23 @@ module.exports = {
                                         Windows.Storage.Streams.RandomAccessStream.copyAndCloseAsync(_stream, fileStream).done(function () {
                                             var _imageUrl = URL.createObjectURL(file);
                                             successCallback(_imageUrl);
-                                        }, function () { errorCallback("Resize picture error."); })
-                                    }, function () { errorCallback("Resize picture error."); })
-                                }, function () { errorCallback("Resize picture error."); })
-                            })
-
-                        }
-                    }
-
+                                        }, function () { errorCallback("Resize picture error."); });
+                                    }, function () { errorCallback("Resize picture error."); });
+                                }, function () { errorCallback("Resize picture error."); });
+                            });
+                        };
+                    };
                     reader.readAsDataURL(filePhoto);
-
-                }
+                };
                 var failCB = function () {
-                    errorCallback("File not found.")
-                }
+                    errorCallback("File not found.");
+                };
                 fileEntry.file(successCB, failCB);
-            }
+            };
 
             var fail = function (fileError) {
                 errorCallback("FileError, code:" + fileError.code);
-            }
+            };
             Windows.Storage.StorageFolder.getFolderFromPathAsync(packageId.path).done(function (storageFolder) {
                 file.copyAsync(storageFolder, file.name, Windows.Storage.NameCollisionOption.replaceExisting).then(function (storageFile) {
                     success(new FileEntry(storageFile.name, storageFile.path));
@@ -99,17 +96,16 @@ module.exports = {
                 }, function () {
                     errorCallback("Folder not access.");
                 });
-            })
+            });
 
-        }
+        };
 
         // because of asynchronous method, so let the successCallback be called in it.
         var resizeImageBase64 = function (file) {
             var imgObj = new Image();
             var success = function (fileEntry) {
                 var successCB = function (filePhoto) {
-                    var filePhoto = filePhoto,
-                        fileType = file.contentType,
+                    var fileType = file.contentType,
                         reader = new FileReader();
                     reader.onloadend = function () {
                         var image = new Image();
@@ -133,21 +129,21 @@ module.exports = {
                             var arr = finalFile.split(",");
                             var newStr = finalFile.substr(arr[0].length + 1);
                             successCallback(newStr);
-                        }
-                    }
+                        };
+                    };
 
                     reader.readAsDataURL(filePhoto);
 
-                }
+                };
                 var failCB = function () {
-                    errorCallback("File not found.")
-                }
+                    errorCallback("File not found.");
+                };
                 fileEntry.file(successCB, failCB);
-            }
+            };
 
             var fail = function (fileError) {
                 errorCallback("FileError, code:" + fileError.code);
-            }
+            };
             Windows.Storage.StorageFolder.getFolderFromPathAsync(packageId.path).done(function (storageFolder) {
                 file.copyAsync(storageFolder, file.name, Windows.Storage.NameCollisionOption.replaceExisting).then(function (storageFile) {
                     success(new FileEntry(storageFile.name, storageFile.path));
@@ -156,9 +152,9 @@ module.exports = {
                 }, function () {
                     errorCallback("Folder not access.");
                 });
-            })
+            });
 
-        }
+        };
 
         if (sourceType != Camera.PictureSourceType.CAMERA) {
             var fileOpenPicker = new Windows.Storage.Pickers.FileOpenPicker();
@@ -185,7 +181,7 @@ module.exports = {
                                 }, function () {
                                     errorCallback("Folder not access.");
                                 });
-                            })
+                            });
 
                         }
                     }
@@ -196,7 +192,7 @@ module.exports = {
                             Windows.Storage.FileIO.readBufferAsync(file).done(function (buffer) {
                                 var strBase64 = Windows.Security.Cryptography.CryptographicBuffer.encodeToBase64String(buffer);
                                 successCallback(strBase64);
-                            })
+                            });
                         }
 
                     }
@@ -205,8 +201,8 @@ module.exports = {
                     errorCallback("User didn't choose a file.");
                 }
             }, function () {
-                errorCallback("User didn't choose a file.")
-            })
+                errorCallback("User didn't choose a file.");
+            });
         }
         else {
 
@@ -254,7 +250,7 @@ module.exports = {
                                     }, function () {
                                         errorCallback("Folder not access.");
                                     });
-                                })
+                                });
                             }
                         } else {
                             if (targetHeight > 0 && targetWidth > 0) {
@@ -263,15 +259,15 @@ module.exports = {
                                 Windows.Storage.FileIO.readBufferAsync(picture).done(function (buffer) {
                                     var strBase64 = Windows.Security.Cryptography.CryptographicBuffer.encodeToBase64String(buffer);
                                     successCallback(strBase64);
-                                })
+                                });
                             }
                         }
-                    }
+                    };
                     // save to photo album errorCallback
                     var fail = function () {
                         //errorCallback("FileError, code:" + fileError.code);
                         errorCallback("Save fail.");
-                    }
+                    };
 
                     if (saveToPhotoAlbum) {
                         Windows.Storage.StorageFile.getFileFromPathAsync(picture.path).then(function (storageFile) {
@@ -279,8 +275,8 @@ module.exports = {
                                 success(storageFile);
                             }, function () {
                                 fail();
-                            })
-                        })
+                            });
+                        });
                         //var directory = new DirectoryEntry("Pictures", parentPath);
                         //new FileEntry(picture.name, picture.path).copyTo(directory, null, success, fail);
                     } else {
@@ -297,7 +293,7 @@ module.exports = {
                                     }, function () {
                                         errorCallback("Folder not access.");
                                     });
-                                })
+                                });
                             }
                         } else {
                             if (targetHeight > 0 && targetWidth > 0) {
@@ -306,7 +302,7 @@ module.exports = {
                                 Windows.Storage.FileIO.readBufferAsync(picture).done(function (buffer) {
                                     var strBase64 = Windows.Security.Cryptography.CryptographicBuffer.encodeToBase64String(buffer);
                                     successCallback(strBase64);
-                                })
+                                });
                             }
                         }
                     }
@@ -315,7 +311,7 @@ module.exports = {
                 }
             }, function () {
                 errorCallback("Fail to capture a photo.");
-            })
+            });
         }
     }
 };
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/ecf62733/lib/windows8/plugin/windows8/FileProxy.js
----------------------------------------------------------------------
diff --git a/lib/windows8/plugin/windows8/FileProxy.js b/lib/windows8/plugin/windows8/FileProxy.js
index bbc03b4..749dda2 100644
--- a/lib/windows8/plugin/windows8/FileProxy.js
+++ b/lib/windows8/plugin/windows8/FileProxy.js
@@ -1,6 +1,6 @@
 var cordova = require('cordova'),
-	FileError = require('fileError'),
-	Flags = requrie('flags');
+    FileError = require('fileError'),
+    Flags = require('flags');
 
 
 module.exports = { //Merges with common
@@ -9,59 +9,59 @@ module.exports = { //Merges with common
 
 
         Windows.Storage.StorageFile.getFileFromPathAsync(args[0]).done(
-			function (storageFile) {
-				storageFile.getBasicPropertiesAsync().then(
-					function (basicProperties) {
-						win(new File(storageFile.name, storageFile.path, storageFile.fileType, basicProperties.dateModified, basicProperties.size));
-					}, function () {
-						fail(FileError.NOT_READABLE_ERR);
-					}
-				)
-			}, function () {
-				fail(FileError.NOT_FOUND_ERR)
-			}
-    	)
+            function (storageFile) {
+                storageFile.getBasicPropertiesAsync().then(
+                    function (basicProperties) {
+                        win(new File(storageFile.name, storageFile.path, storageFile.fileType, basicProperties.dateModified, basicProperties.size));
+                    }, function () {
+                        fail(FileError.NOT_READABLE_ERR);
+                    }
+                );
+            }, function () {
+                fail(FileError.NOT_FOUND_ERR);
+            }
+        );
     },
 
     getMetadata:function(win,fail,args) {
-		// this.fullPath
-		// this.isDirectory
-		// this.isFile
-		if (this.isFile) {
-			Windows.Storage.StorageFile.getFilFromPathAsync(args[0]).done(
-				function (storageFile) {
-					storageFile.getBasicPropertiesAsync().then(
-						function (basicProperties) {
-							success(basicProperties.dateModified);
-						},
-		                function () {
-							fail(FileError.NOT_READABLE_ERR);
-		                }
-					)
-				},
-		        function () {
-					fail(FileError.NOT_READABLE_ERR);
-		        }
-		    )
-		}
-
-		if (this.isDirectory) {
-			Windows.Storage.StorageFolder.getFolderFromPathAsync(this.fullPath).done(
-				function (storageFolder) {
-					storageFolder.getBasicPropertiesAsync().then(
-						function (basicProperties) {
-							success(basicProperties.dateModified);
-						},
-						function () {
-							fail(FileError.NOT_FOUND_ERR);
-						}
-					);
-				},
-				function () {
-					fail(FileError.NOT_READABLE_ERR);
-				}
-			)
-		}
+        // this.fullPath
+        // this.isDirectory
+        // this.isFile
+        if (this.isFile) {
+            Windows.Storage.StorageFile.getFilFromPathAsync(args[0]).done(
+                function (storageFile) {
+                    storageFile.getBasicPropertiesAsync().then(
+                        function (basicProperties) {
+                            success(basicProperties.dateModified);
+                        },
+                        function () {
+                            fail(FileError.NOT_READABLE_ERR);
+                        }
+                    );
+                },
+                function () {
+                    fail(FileError.NOT_READABLE_ERR);
+                }
+            );
+        }
+
+        if (this.isDirectory) {
+            Windows.Storage.StorageFolder.getFolderFromPathAsync(this.fullPath).done(
+                function (storageFolder) {
+                    storageFolder.getBasicPropertiesAsync().then(
+                        function (basicProperties) {
+                            success(basicProperties.dateModified);
+                        },
+                        function () {
+                            fail(FileError.NOT_FOUND_ERR);
+                        }
+                    );
+                },
+                function () {
+                    fail(FileError.NOT_READABLE_ERR);
+                }
+            );
+        }
     },
 
     getParent:function(win,fail,args) { // ["fullPath"]
@@ -69,73 +69,73 @@ module.exports = { //Merges with common
 
 
 
-	    var storageFolderPer = Windows.Storage.ApplicationData.current.localFolder;
-	    var storageFolderTem = Windows.Storage.ApplicationData.current.temporaryFolder;
+        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;
-	    } else if (fullPath == FileSystemTemproraryRoot) {
-	        win(new DirectoryEntry(storageFolderTem.name, storageFolderTem.path));
-	        return;
-	    }
-	    var splitArr = fullPath.split(new RegExp(/\/|\\/g));
+        if (fullPath == FileSystemPersistentRoot) {
+            win(new DirectoryEntry(storageFolderPer.name, storageFolderPer.path));
+            return;
+        } else if (fullPath == FileSystemTemproraryRoot) {
+            win(new DirectoryEntry(storageFolderTem.name, storageFolderTem.path));
+            return;
+        }
+        var splitArr = fullPath.split(new RegExp(/\/|\\/g));
 
-	    var popItem = splitArr.pop();
+        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) },
-	        function () { fail(FileError.INVALID_STATE_ERR) }
-	    );
+        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); }
+        );
     },
 
     readAsText:function(win,fail,args) {
         var enc = args[1];
 
         Windows.Storage.StorageFile.getFileFromPathAsync(args[0]).done(
-			function (storageFile) {
-				var value = Windows.Storage.Streams.UnicodeEncoding.utf8;
-		        if (enc == 'Utf16LE' || enc == 'utf16LE') {
-		            value = Windows.Storage.Streams.UnicodeEncoding.utf16LE;
-		        }else if (enc == 'Utf16BE' || enc == 'utf16BE') {
-		            value = Windows.Storage.Streams.UnicodeEncoding.utf16BE;
-		        }
-		        Windows.Storage.FileIO.readTextAsync(storageFile, value).done(
-					function (fileContent) {
-						win(fileContent);
-		        	},
-		        	function () {
-						fail(FileError.ENCODING_ERR)
-					}
-				);
-    		}, function () {
-				fail(FileError.NOT_FOUND_ERR)
-			}
-		)
+            function (storageFile) {
+                var value = Windows.Storage.Streams.UnicodeEncoding.utf8;
+                if (enc == 'Utf16LE' || enc == 'utf16LE') {
+                    value = Windows.Storage.Streams.UnicodeEncoding.utf16LE;
+                }else if (enc == 'Utf16BE' || enc == 'utf16BE') {
+                    value = Windows.Storage.Streams.UnicodeEncoding.utf16BE;
+                }
+                Windows.Storage.FileIO.readTextAsync(storageFile, value).done(
+                    function (fileContent) {
+                        win(fileContent);
+                    },
+                    function () {
+                        fail(FileError.ENCODING_ERR);
+                    }
+                );
+            }, function () {
+                fail(FileError.NOT_FOUND_ERR);
+            }
+        );
     },
 
     readAsDataURL:function(win,fail,args) {
 
 
         Windows.Storage.StorageFile.getFileFromPathAsync(args[0]).then(
-			function (storageFile) {
-		        Windows.Storage.FileIO.readBufferAsync(storageFile).done(
-					function (buffer) {
-		            	var strBase64 = Windows.Security.Cryptography.CryptographicBuffer.encodeToBase64String(buffer);
-		            	//the method encodeToBase64String will add "77u/" as a prefix, so we should remove it
-		            	if(String(strBase64).substr(0,4) == "77u/") {
-		                	strBase64 = strBase64.substr(4);
-		            	}
-		            	var mediaType = storageFile.contentType;
-		            	var result = "data:" + mediaType + ";base64," + strBase64;
-						win(result);
-		        	}
-				)
-			}, function () {
-				fail(FileError.NOT_FOUND_ERR)
-			}
-		)
+            function (storageFile) {
+                Windows.Storage.FileIO.readBufferAsync(storageFile).done(
+                    function (buffer) {
+                        var strBase64 = Windows.Security.Cryptography.CryptographicBuffer.encodeToBase64String(buffer);
+                        //the method encodeToBase64String will add "77u/" as a prefix, so we should remove it
+                        if(String(strBase64).substr(0,4) == "77u/") {
+                            strBase64 = strBase64.substr(4);
+                        }
+                        var mediaType = storageFile.contentType;
+                        var result = "data:" + mediaType + ";base64," + strBase64;
+                        win(result);
+                    }
+                );
+            }, function () {
+                fail(FileError.NOT_FOUND_ERR);
+            }
+        );
     },
 
     getDirectory:function(win,fail,args) {
@@ -143,53 +143,53 @@ module.exports = { //Merges with common
         // path
         // options
         var path = args[1];
-		var options = args[2];
+        var options = args[2];
 
         var flag = "";
-		if (options != null) {
-			flag = new Flags(options.create, options.exclusive);
-		} else {
-			flag = new Flags(false, false);
-		};
-
-		path = String(path).split(" ").join("\ ");
-
-		Windows.Storage.StorageFolder.getFolderFromPathAsync(args[0]).then(
-			function (storageFolder) {
-				if (flag.create == true && flag.exclusive == true) {
-					storageFolder.createFolderAsync(path, Windows.Storage.CreationCollisionOption.failIfExists).done(
-						function (storageFolder) {
-							win(new DirectoryEntry(storageFolder.name, storageFolder.path))
-						}, function () {
-							fail(FileError.PATH_EXISTS_ERR);
-						}
-					)
-				} 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))
-						}, function () {
-							fail(FileError.INVALID_MODIFICATION_ERR);
-						}
-					)
-				} else if (flag.create == false) {
-					if (/\?|\\|\*|\||\"|<|>|\:|\//g.test(path)) {
-						fail(FileError.ENCODING_ERR);
-						return;
-					};
-
-					storageFolder.getFolderAsync(path).done(
-						function (storageFolder) {
-							win(new DirectoryEntry(storageFolder.name, storageFolder.path))
-						}, function () {
-							fail(FileError.NOT_FOUND_ERR);
-						}
-					)
-				}
-			}, function () {
-				fail(FileError.NOT_FOUND_ERR)
-			}
-		)
+        if (options !== null) {
+            flag = new Flags(options.create, options.exclusive);
+        } else {
+            flag = new Flags(false, false);
+        }
+
+        path = String(path).split(" ").join("\ ");
+
+        Windows.Storage.StorageFolder.getFolderFromPathAsync(args[0]).then(
+            function (storageFolder) {
+                if (flag.create === true && flag.exclusive === true) {
+                    storageFolder.createFolderAsync(path, Windows.Storage.CreationCollisionOption.failIfExists).done(
+                        function (storageFolder) {
+                            win(new DirectoryEntry(storageFolder.name, storageFolder.path));
+                        }, function () {
+                            fail(FileError.PATH_EXISTS_ERR);
+                        }
+                    );
+                } 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));
+                        }, function () {
+                            fail(FileError.INVALID_MODIFICATION_ERR);
+                        }
+                    );
+                } else if (flag.create === false) {
+                    if (/\?|\\|\*|\||\"|<|>|\:|\//g.test(path)) {
+                        fail(FileError.ENCODING_ERR);
+                        return;
+                    }
+
+                    storageFolder.getFolderAsync(path).done(
+                        function (storageFolder) {
+                            win(new DirectoryEntry(storageFolder.name, storageFolder.path));
+                        }, function () {
+                            fail(FileError.NOT_FOUND_ERR);
+                        }
+                    );
+                }
+            }, function () {
+                fail(FileError.NOT_FOUND_ERR);
+            }
+        );
     },
 
     remove:function(win,fail,args) {
@@ -198,54 +198,54 @@ module.exports = { //Merges with common
         // this.isFile
 
         if (this.isFile) {
-	        Windows.Storage.StorageFile.getFileFromPathAsync(fullPath).done(function (storageFile) {
-	            storageFile.deleteAsync().done(successCallback, function () {
-	                fail(FileError.INVALID_MODIFICATION_ERR);
-
-	            });
-	        });
-    	}
-	    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;
-	                var storageFolderTem = Windows.Storage.ApplicationData.current.temporaryFolder;
-	                if (fullPath == storageFolderPer.path || fullPath == storageFolderTem.path) {
-	                    fail(FileError.NO_MODIFICATION_ALLOWED_ERR);
-	                    return;
-	                }
-	                storageFolder.createFileQuery().getFilesAsync().then(function (fileList) {
-
-	                    if (fileList.length == 0) {
-	                        storageFolder.createFolderQuery().getFoldersAsync().then(function (folderList) {
-
-	                            if (folderList.length == 0) {
-	                                storageFolder.deleteAsync().done(successCallback, function () {
-	                                    fail(FileError.INVALID_MODIFICATION_ERR);
-
-	                                });
-	                            } else {
-	                                fail(FileError.INVALID_MODIFICATION_ERR);
-	                            }
-	                        })
-	                    } else {
-	                        fail(FileError.INVALID_MODIFICATION_ERR);
-	                    }
-	                });
-
-	            }, function () {
-	                fail(FileError.INVALID_MODIFICATION_ERR);
-
-	            })
-
-
-	        }
-	        removeEntry();
-	    }
+            Windows.Storage.StorageFile.getFileFromPathAsync(fullPath).done(function (storageFile) {
+                storageFile.deleteAsync().done(successCallback, function () {
+                    fail(FileError.INVALID_MODIFICATION_ERR);
+
+                });
+            });
+        }
+        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;
+                    var storageFolderTem = Windows.Storage.ApplicationData.current.temporaryFolder;
+                    if (fullPath == storageFolderPer.path || fullPath == storageFolderTem.path) {
+                        fail(FileError.NO_MODIFICATION_ALLOWED_ERR);
+                        return;
+                    }
+                    storageFolder.createFileQuery().getFilesAsync().then(function (fileList) {
+
+                        if (fileList.length === 0) {
+                            storageFolder.createFolderQuery().getFoldersAsync().then(function (folderList) {
+
+                                if (folderList.length === 0) {
+                                    storageFolder.deleteAsync().done(successCallback, function () {
+                                        fail(FileError.INVALID_MODIFICATION_ERR);
+
+                                    });
+                                } else {
+                                    fail(FileError.INVALID_MODIFICATION_ERR);
+                                }
+                            });
+                        } else {
+                            fail(FileError.INVALID_MODIFICATION_ERR);
+                        }
+                    });
+
+                }, function () {
+                    fail(FileError.INVALID_MODIFICATION_ERR);
+
+                });
+
+
+            };
+            removeEntry();
+        }
 
     },
 
@@ -268,7 +268,7 @@ module.exports = { //Merges with common
                     var filePromiseArr = [];
 
                     fileListPromise.then(function (fileList) {
-                        if (fileList != null) {
+                        if (fileList !== null) {
                             for (var i = 0; i < fileList.length; i++) {
                                 var filePromise = fileList[i].deleteAsync();
                                 filePromiseArr.push(filePromise);
@@ -278,7 +278,7 @@ module.exports = { //Merges with common
                             var folderListPromise = storageFolder.createFolderQuery().getFoldersAsync();
                             folderListPromise.then(function (folderList) {
                                 var folderPromiseArr = [];
-                                if (folderList.length != 0) {
+                                if (folderList.length !== 0) {
                                     for (var j = 0; j < folderList.length; j++) {
 
                                         folderPromiseArr.push(removeFolders(folderList[j].path));
@@ -291,98 +291,98 @@ module.exports = { //Merges with common
                                 }
                             }, function () { });
                        });
-                    }, function () { })
+                    }, function () { });
                 });
             });
-        }
+        };
         removeFolders(storageFolder.path).then(function () {
             Windows.Storage.StorageFolder.getFolderFromPathAsync(storageFolder.path).then(
                 function () {},
                 function () {
-                    if (typeof successCallback != 'undefined' && successCallback != null) { successCallback(); }
-                })
-        	});
-    	})
+                    if (typeof successCallback !== 'undefined' && successCallback !== null) { successCallback(); }
+                });
+            });
+        });
     },
 
     getFile:function(win,fail,args) {
         var fullPath = args[0];
-		var path = args[1];
+        var path = args[1];
         var options = args[2];
 
         var flag = "";
-		if (options != null) {
-			flag = new Flags(options.create, options.exclusive);
-		} else {
-			flag = new Flags(false, false);
-    	}
-
-    	path = String(path).split(" ").join("\ ");
-
-    	Windows.Storage.StorageFolder.getFolderFromPathAsync(fullPath).then(
-			function (storageFolder) {
-		        if (flag.create == true && flag.exclusive == true) {
-		            storageFolder.createFileAsync(path, Windows.Storage.CreationCollisionOption.failIfExists).done(
-						function (storageFile) {
-		                	win(new FileEntry(storageFile.name, storageFile.path))
-		            	}, function () {
-							fail(FileError.PATH_EXISTS_ERR);
-		            	}
-		            )
-		        } else if (flag.create == true && flag.exclusive == false) {
-		            storageFolder.createFileAsync(path, Windows.Storage.CreationCollisionOption.openIfExists).done(
-						function (storageFile) {
-		                	win(new FileEntry(storageFile.name, storageFile.path))
-		            	}, function () {
-							fail(FileError.INVALID_MODIFICATION_ERR);
-		            	}
-					)
-		        } else if (flag.create == false) {
-		            if (/\?|\\|\*|\||\"|<|>|\:|\//g.test(path)) {
-		                fail(FileError.ENCODING_ERR);
-		                return;
-		            };
-		            storageFolder.getFileAsync(path).done(
-						function (storageFile) {
-		                	win(new FileEntry(storageFile.name, storageFile.path))
-		            	}, function () {
-		                	fail(FileError.NOT_FOUND_ERR);
-		            	}
-					)
-		        }
-		    }, function () {
-		        fail(FileError.NOT_FOUND_ERR)
-    		}
-    	)
+        if (options !=- null) {
+            flag = new Flags(options.create, options.exclusive);
+        } else {
+            flag = new Flags(false, false);
+        }
+
+        path = String(path).split(" ").join("\ ");
+
+        Windows.Storage.StorageFolder.getFolderFromPathAsync(fullPath).then(
+            function (storageFolder) {
+                if (flag.create === true && flag.exclusive === true) {
+                    storageFolder.createFileAsync(path, Windows.Storage.CreationCollisionOption.failIfExists).done(
+                        function (storageFile) {
+                            win(new FileEntry(storageFile.name, storageFile.path));
+                        }, function () {
+                            fail(FileError.PATH_EXISTS_ERR);
+                        }
+                    );
+                } else if (flag.create === true && flag.exclusive === false) {
+                    storageFolder.createFileAsync(path, Windows.Storage.CreationCollisionOption.openIfExists).done(
+                        function (storageFile) {
+                            win(new FileEntry(storageFile.name, storageFile.path));
+                        }, function () {
+                            fail(FileError.INVALID_MODIFICATION_ERR);
+                        }
+                    );
+                } else if (flag.create === false) {
+                    if (/\?|\\|\*|\||\"|<|>|\:|\//g.test(path)) {
+                        fail(FileError.ENCODING_ERR);
+                        return;
+                    }
+                    storageFolder.getFileAsync(path).done(
+                        function (storageFile) {
+                            win(new FileEntry(storageFile.name, storageFile.path));
+                        }, function () {
+                            fail(FileError.NOT_FOUND_ERR);
+                        }
+                    );
+                }
+            }, function () {
+                fail(FileError.NOT_FOUND_ERR);
+            }
+        );
     },
 
     readEntries:function(win,fail,args) { // ["fullPath"]
 
 
         var result = new Array();
-	    var path = args[0];
-	    Windows.Storage.StorageFolder.getFolderFromPathAsync(path).then(function (storageFolder) {
-	        var promiseArr = [];
-	        var index = 0;
-	        promiseArr[index++] = storageFolder.createFileQuery().getFilesAsync().then(function (fileList) {
-	            if (fileList != null) {
-	                for (var i = 0; i < fileList.length; i++) {
-	                    result.push(new FileEntry(fileList[i].name, fileList[i].path));
-	                }
-	            }
-	        })
-	        promiseArr[index++] = storageFolder.createFolderQuery().getFoldersAsync().then(function (folderList) {
-	            if (folderList != null) {
-	                for (var j = 0; j < folderList.length; j++) {
-	                    result.push(new FileEntry(folderList[j].name, folderList[j].path));
-	                }
-	            }
-	        })
-	        WinJS.Promise.join(promiseArr).then(function () {
-	            win(result);
-	        })
-
-	    }, function () { fail(FileError.NOT_FOUND_ERR) })
+        var path = args[0];
+        Windows.Storage.StorageFolder.getFolderFromPathAsync(path).then(function (storageFolder) {
+            var promiseArr = [];
+            var index = 0;
+            promiseArr[index++] = storageFolder.createFileQuery().getFilesAsync().then(function (fileList) {
+                if (fileList !== null) {
+                    for (var i = 0; i < fileList.length; i++) {
+                        result.push(new FileEntry(fileList[i].name, fileList[i].path));
+                    }
+                }
+            });
+            promiseArr[index++] = storageFolder.createFolderQuery().getFoldersAsync().then(function (folderList) {
+                if (folderList !== null) {
+                    for (var j = 0; j < folderList.length; j++) {
+                        result.push(new FileEntry(folderList[j].name, folderList[j].path));
+                    }
+                }
+            });
+            WinJS.Promise.join(promiseArr).then(function () {
+                win(result);
+            });
+
+        }, function () { fail(FileError.NOT_FOUND_ERR); });
     },
 
     write:function(win,fail,args) {
@@ -390,18 +390,18 @@ module.exports = { //Merges with common
         // this.position
 
         Windows.Storage.StorageFile.getFileFromPathAsync(args[0]).done(
-			function (storageFile) {
-				Windows.Storage.FileIO.writeTextAsync(storageFile,text,Windows.Storage.Streams.UnicodeEncoding.utf8).done(
-					function() {
-						win(String(text).length);
-					}, function () {
-						fail(FileError.INVALID_MODIFICATION_ERR);
-					}
-				);
-			}, function() {
-				fail(FileError.NOT_FOUND_ERR)
-			}
-		)
+            function (storageFile) {
+                Windows.Storage.FileIO.writeTextAsync(storageFile,text,Windows.Storage.Streams.UnicodeEncoding.utf8).done(
+                    function() {
+                        win(String(text).length);
+                    }, function () {
+                        fail(FileError.INVALID_MODIFICATION_ERR);
+                    }
+                );
+            }, function() {
+                fail(FileError.NOT_FOUND_ERR);
+            }
+        );
     },
 
     truncate:function(win,fail,args) { // ["fileName","size"]
@@ -409,44 +409,44 @@ module.exports = { //Merges with common
         var size = args[1];
 
         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) {
-	                win(this.length);
-	                return;
-	            }
-	            if (Number(size) >= 0) {
-	                Windows.Storage.FileIO.readTextAsync(storageFile, Windows.Storage.Streams.UnicodeEncoding.utf8).then(function (fileContent) {
-	                    fileContent = fileContent.substr(0, size);
-	                    var fullPath = storageFile.path;
-	                    var name = storageFile.name;
-	                    var entry = new Entry(true, false, name, fullPath);
-	                    var parentPath = "";
-	                    do {
-	                        var successCallBack = function (entry) {
-	                            parentPath = entry.fullPath;
-	                        }
-	                        entry.getParent(successCallBack, null);
-	                    }
-	                    while (parentPath == "");
-	                    storageFile.deleteAsync().then(function () {
-	                        Windows.Storage.StorageFolder.getFolderFromPathAsync(parentPath).then(function (storageFolder) {
-	                            storageFolder.createFileAsync(name).then(function (newStorageFile) {
-	                                Windows.Storage.FileIO.writeTextAsync(newStorageFile, fileContent).done(function () {
-	                                    win(String(fileContent).length);
-	                                }, function () {
-	                                    fail(FileError.NO_MODIFICATION_ALLOWED_ERR);
-	                                });
-	                            })
-	                        })
-	                    })
-	                }, function () { fail(FileError.NOT_FOUND_ERR) });
-	            }
-	        })
-	    }, function () { fail(FileError.NOT_FOUND_ERR) })
+            //the current length of the file.
+            var leng = 0;
+
+            storageFile.getBasicPropertiesAsync().then(function (basicProperties) {
+                leng = basicProperties.size;
+                if (Number(size) >= leng) {
+                    win(this.length);
+                    return;
+                }
+                if (Number(size) >= 0) {
+                    Windows.Storage.FileIO.readTextAsync(storageFile, Windows.Storage.Streams.UnicodeEncoding.utf8).then(function (fileContent) {
+                        fileContent = fileContent.substr(0, size);
+                        var fullPath = storageFile.path;
+                        var name = storageFile.name;
+                        var entry = new Entry(true, false, name, fullPath);
+                        var parentPath = "";
+                        do {
+                            var successCallBack = function (entry) {
+                                parentPath = entry.fullPath;
+                            };
+                            entry.getParent(successCallBack, null);
+                        }
+                        while (parentPath === "");
+                        storageFile.deleteAsync().then(function () {
+                            Windows.Storage.StorageFolder.getFolderFromPathAsync(parentPath).then(function (storageFolder) {
+                                storageFolder.createFileAsync(name).then(function (newStorageFile) {
+                                    Windows.Storage.FileIO.writeTextAsync(newStorageFile, fileContent).done(function () {
+                                        win(String(fileContent).length);
+                                    }, function () {
+                                        fail(FileError.NO_MODIFICATION_ALLOWED_ERR);
+                                    });
+                                });
+                            });
+                        });
+                    }, function () { fail(FileError.NOT_FOUND_ERR); });
+                }
+            });
+        }, function () { fail(FileError.NOT_FOUND_ERR); });
     },
 
     copyTo:function(win,fail,args) { // ["fullPath","parent", "newName"]
@@ -455,107 +455,107 @@ module.exports = { //Merges with common
         var name = args[2];
 
         //name can't be invalid
-	    if (/\?|\\|\*|\||\"|<|>|\:|\//g.test(name)) {
-	        fail(FileError.ENCODING_ERR);
-	        return;
-	    };
-	    // copy
-	    var copyFiles = "";
-	    if (this.isFile) {
-	        copyFiles = function (srcPath, parentPath) {
-	            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);
-	            })
-	        };
-	    }
-
-	    if (this.isDirectory) {
-	        copyFiles = function (srcPath, parentPath) {
-	            return new WinJS.Promise(function (complete) {
-	                Windows.Storage.StorageFolder.getFolderFromPathAsync(srcPath).then(function (storageFolder) {
-	                    storageFolder.createFileQuery().getFilesAsync().then(function (fileList) {
-	                        var filePromiseArr = [];
-	                        if (fileList) {
-	                            Windows.Storage.StorageFolder.getFolderFromPathAsync(parentPath).then(function (targetStorageFolder) {
-	                                for (var i = 0; i < fileList.length; i++) {
-	                                    filePromiseArr.push(fileList[i].copyAsync(targetStorageFolder));
-	                                }
-	                                WinJS.Promise.join(filePromiseArr).then(function () {
-	                                    storageFolder.createFolderQuery().getFoldersAsync().then(function (folderList) {
-	                                        var folderPromiseArr = [];
-	                                        if (folderList.length == 0) { complete(); }
-	                                        else {
-
-	                                            Windows.Storage.StorageFolder.getFolderFromPathAsync(parentPath).then(function (storageFolderTarget) {
-	                                                var tempPromiseArr = [];
-	                                                var index = 0;
-	                                                for (var j = 0; j < folderList.length; j++) {
-	                                                    tempPromiseArr[index++] = storageFolderTarget.createFolderAsync(folderList[j].name).then(function (targetFolder) {
-	                                                        folderPromiseArr.push(copyFiles(folderList[j].path, targetFolder.path));
-	                                                    })
-	                                                }
-	                                                WinJS.Promise.join(tempPromiseArr).then(function () {
-	                                                    WinJS.Promise.join(folderPromiseArr).then(complete);
-	                                                });
-	                                            })
-	                                        }
-	                                    })
-	                                })
-	                            })
-	                        }
-	                    })
-	                })
-	            })
-	        }
-	    }
-
-	    // copy
-	    var isFile = this.isFile;
-	    var isDirectory = this.isDirectory;
-	    var copyFinish = function (srcPath, parentPath) {
-	        if (isFile) {
-	            copyFiles(srcPath, parentPath);
-	        }
-	        if (isDirectory) {
-	            Windows.Storage.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) {
-	                        fail(FileError.INVALID_MODIFICATION_ERR);
-	                        return;
-	                    }
-	                    //can't copy into itself
-	                    if (srcPath == parentPath) {
-	                        fail(FileError.INVALID_MODIFICATION_ERR);
-	                        return;
-	                    }
-	                    copyFiles(srcPath, newStorageFolder.path).then(function () {
-	                        Windows.Storage.StorageFolder.getFolderFromPathAsync(newStorageFolder.path).done(
-	                            function (storageFolder) {
-	                            success(new DirectoryEntry(storageFolder.name, storageFolder.path));
-	                            },
-	                            function () { fail(FileError.NOT_FOUND_ERR) }
-	                        )
-	                    })
-	                }, function () { fail(FileError.INVALID_MODIFICATION_ERR); })
-	            }, function () { fail(FileError.INVALID_MODIFICATION_ERR);})
-	        }
-	    };
-	    copyFinish(srcPath, parentFullPath);
+        if (/\?|\\|\*|\||\"|<|>|\:|\//g.test(name)) {
+            fail(FileError.ENCODING_ERR);
+            return;
+        }
+        // copy
+        var copyFiles = "";
+        if (this.isFile) {
+            copyFiles = function (srcPath, parentPath) {
+                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);
+                });
+            };
+        }
+
+        if (this.isDirectory) {
+            copyFiles = function (srcPath, parentPath) {
+                return new WinJS.Promise(function (complete) {
+                    Windows.Storage.StorageFolder.getFolderFromPathAsync(srcPath).then(function (storageFolder) {
+                        storageFolder.createFileQuery().getFilesAsync().then(function (fileList) {
+                            var filePromiseArr = [];
+                            if (fileList) {
+                                Windows.Storage.StorageFolder.getFolderFromPathAsync(parentPath).then(function (targetStorageFolder) {
+                                    for (var i = 0; i < fileList.length; i++) {
+                                        filePromiseArr.push(fileList[i].copyAsync(targetStorageFolder));
+                                    }
+                                    WinJS.Promise.join(filePromiseArr).then(function () {
+                                        storageFolder.createFolderQuery().getFoldersAsync().then(function (folderList) {
+                                            var folderPromiseArr = [];
+                                            if (folderList.length === 0) { complete(); }
+                                            else {
+
+                                                Windows.Storage.StorageFolder.getFolderFromPathAsync(parentPath).then(function (storageFolderTarget) {
+                                                    var tempPromiseArr = [];
+                                                    var index = 0;
+                                                    for (var j = 0; j < folderList.length; j++) {
+                                                        tempPromiseArr[index++] = storageFolderTarget.createFolderAsync(folderList[j].name).then(function (targetFolder) {
+                                                            folderPromiseArr.push(copyFiles(folderList[j].path, targetFolder.path));
+                                                        });
+                                                    }
+                                                    WinJS.Promise.join(tempPromiseArr).then(function () {
+                                                        WinJS.Promise.join(folderPromiseArr).then(complete);
+                                                    });
+                                                });
+                                            }
+                                        });
+                                    });
+                                });
+                            }
+                        });
+                    });
+                });
+            };
+        }
+
+        // copy
+        var isFile = this.isFile;
+        var isDirectory = this.isDirectory;
+        var copyFinish = function (srcPath, parentPath) {
+            if (isFile) {
+                copyFiles(srcPath, parentPath);
+            }
+            if (isDirectory) {
+                Windows.Storage.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) {
+                            fail(FileError.INVALID_MODIFICATION_ERR);
+                            return;
+                        }
+                        //can't copy into itself
+                        if (srcPath == parentPath) {
+                            fail(FileError.INVALID_MODIFICATION_ERR);
+                            return;
+                        }
+                        copyFiles(srcPath, newStorageFolder.path).then(function () {
+                            Windows.Storage.StorageFolder.getFolderFromPathAsync(newStorageFolder.path).done(
+                                function (storageFolder) {
+                                success(new DirectoryEntry(storageFolder.name, storageFolder.path));
+                                },
+                                function () { fail(FileError.NOT_FOUND_ERR); }
+                            );
+                        });
+                    }, function () { fail(FileError.INVALID_MODIFICATION_ERR); });
+                }, function () { fail(FileError.INVALID_MODIFICATION_ERR);});
+            }
+        };
+        copyFinish(srcPath, parentFullPath);
     },
 
     moveTo:function(win,fail,args) { // ["fullPath","parent", "newName"]
@@ -565,202 +565,202 @@ module.exports = { //Merges with common
 
 
         //name can't be invalid
-	    if (/\?|\\|\*|\||\"|<|>|\:|\//g.test(name)) {
-	        fail(FileError.ENCODING_ERR);
-	        return;
-	    };
-
-	    var moveFiles = "";
-
-
-	    if (this.isFile) {
-	        moveFiles = function (srcPath, parentPath) {
-	            Windows.Storage.StorageFile.getFileFromPathAsync(srcPath).then(function (storageFile) {
-	                Windows.Storage.StorageFolder.getFolderFromPathAsync(parentPath).then(function (storageFolder) {
-	                    storageFile.moveAsync(storageFolder, name, Windows.Storage.NameCollisionOption.replaceExisting).then(function () {
-	                        success(new FileEntry(name, storageFile.path));
-	                    }, function () {
-	                        fail(FileError.INVALID_MODIFICATION_ERR);
-	                    });
-	                }, function () {
-	                    fail(FileError.NOT_FOUND_ERR);
-	                });
-	            },function () {
-	                fail(FileError.NOT_FOUND_ERR);
-	            })
-	        };
-	    }
-
-	    if (this.isDirectory) {
-	        moveFiles = function (srcPath, parentPath) {
-	            return new WinJS.Promise(function (complete) {
-	                Windows.Storage.StorageFolder.getFolderFromPathAsync(srcPath).then(function (storageFolder) {
-	                    storageFolder.createFileQuery().getFilesAsync().then(function (fileList) {
-	                        var filePromiseArr = [];
-	                        Windows.Storage.StorageFolder.getFolderFromPathAsync(parentPath).then(function (dstStorageFolder) {
-	                            if (fileList) {
-	                                for (var i = 0; i < fileList.length; i++) {
-	                                    filePromiseArr.push(fileList[i].moveAsync(dstStorageFolder));
-	                                }
-	                            }
-	                            WinJS.Promise.join(filePromiseArr).then(function () {
-	                                storageFolder.createFolderQuery().getFoldersAsync().then(function (folderList) {
-	                                    var folderPromiseArr = [];
-	                                    if (folderList.length == 0) {
-	                                        // If failed, we must cancel the deletion of folders & files.So here wo can't delete the folder.
-	                                        complete();
-	                                    }
-	                                    else {
-	                                        Windows.Storage.StorageFolder.getFolderFromPathAsync(parentPath).then(function (storageFolderTarget) {
-	                                            var tempPromiseArr = [];
-	                                            var index = 0;
-	                                            for (var j = 0; j < folderList.length; j++) {
-	                                                tempPromiseArr[index++] = storageFolderTarget.createFolderAsync(folderList[j].name).then(function (targetFolder) {
-	                                                    folderPromiseArr.push(moveFiles(folderList[j].path, targetFolder.path));
-	                                                })
-	                                            }
-	                                            WinJS.Promise.join(tempPromiseArr).then(function () {
-	                                                WinJS.Promise.join(folderPromiseArr).then(complete);
-	                                            });
-	                                        })
-	                                    }
-	                                })
-	                            }, function () { })
-	                        });
-	                    })
-	                });
-	            })
-	        }
-	    }
-
-	    // move
-	    var isDirectory = this.isDirectory;
-	    var isFile = this.isFile;
-	    var moveFinish = function (srcPath, parentPath) {
-
-	        if (isFile) {
-	            //can't copy onto itself
-	            if (srcPath == parentPath + "\\" + name) {
-	                fail(FileError.INVALID_MODIFICATION_ERR);
-	                return;
-	            }
-	            moveFiles(srcPath, parentFullPath);
-	        }
-	        if (isDirectory) {
-	            Windows.Storage.StorageFolder.getFolderFromPathAsync(srcPath).then(function (originFolder) {
-	                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)); }
-	                                    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) })
-	            }, function () { fail(FileError.INVALID_MODIFICATION_ERR); });
-	        }
-	    };
-	    moveFinish(srcPath, parentFullPath);
+        if (/\?|\\|\*|\||\"|<|>|\:|\//g.test(name)) {
+            fail(FileError.ENCODING_ERR);
+            return;
+        }
+
+        var moveFiles = "";
+
+
+        if (this.isFile) {
+            moveFiles = function (srcPath, parentPath) {
+                Windows.Storage.StorageFile.getFileFromPathAsync(srcPath).then(function (storageFile) {
+                    Windows.Storage.StorageFolder.getFolderFromPathAsync(parentPath).then(function (storageFolder) {
+                        storageFile.moveAsync(storageFolder, name, Windows.Storage.NameCollisionOption.replaceExisting).then(function () {
+                            success(new FileEntry(name, storageFile.path));
+                        }, function () {
+                            fail(FileError.INVALID_MODIFICATION_ERR);
+                        });
+                    }, function () {
+                        fail(FileError.NOT_FOUND_ERR);
+                    });
+                },function () {
+                    fail(FileError.NOT_FOUND_ERR);
+                });
+            };
+        }
+
+        if (this.isDirectory) {
+            moveFiles = function (srcPath, parentPath) {
+                return new WinJS.Promise(function (complete) {
+                    Windows.Storage.StorageFolder.getFolderFromPathAsync(srcPath).then(function (storageFolder) {
+                        storageFolder.createFileQuery().getFilesAsync().then(function (fileList) {
+                            var filePromiseArr = [];
+                            Windows.Storage.StorageFolder.getFolderFromPathAsync(parentPath).then(function (dstStorageFolder) {
+                                if (fileList) {
+                                    for (var i = 0; i < fileList.length; i++) {
+                                        filePromiseArr.push(fileList[i].moveAsync(dstStorageFolder));
+                                    }
+                                }
+                                WinJS.Promise.join(filePromiseArr).then(function () {
+                                    storageFolder.createFolderQuery().getFoldersAsync().then(function (folderList) {
+                                        var folderPromiseArr = [];
+                                        if (folderList.length === 0) {
+                                            // If failed, we must cancel the deletion of folders & files.So here wo can't delete the folder.
+                                            complete();
+                                        }
+                                        else {
+                                            Windows.Storage.StorageFolder.getFolderFromPathAsync(parentPath).then(function (storageFolderTarget) {
+                                                var tempPromiseArr = [];
+                                                var index = 0;
+                                                for (var j = 0; j < folderList.length; j++) {
+                                                    tempPromiseArr[index++] = storageFolderTarget.createFolderAsync(folderList[j].name).then(function (targetFolder) {
+                                                        folderPromiseArr.push(moveFiles(folderList[j].path, targetFolder.path));
+                                                    });
+                                                }
+                                                WinJS.Promise.join(tempPromiseArr).then(function () {
+                                                    WinJS.Promise.join(folderPromiseArr).then(complete);
+                                                });
+                                            });
+                                        }
+                                    });
+                                }, function () { });
+                            });
+                        });
+                    });
+                });
+            };
+        }
+
+        // move
+        var isDirectory = this.isDirectory;
+        var isFile = this.isFile;
+        var moveFinish = function (srcPath, parentPath) {
+
+            if (isFile) {
+                //can't copy onto itself
+                if (srcPath == parentPath + "\\" + name) {
+                    fail(FileError.INVALID_MODIFICATION_ERR);
+                    return;
+                }
+                moveFiles(srcPath, parentFullPath);
+            }
+            if (isDirectory) {
+                Windows.Storage.StorageFolder.getFolderFromPathAsync(srcPath).then(function (originFolder) {
+                    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)); }
+                                        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); });
+                }, function () { fail(FileError.INVALID_MODIFICATION_ERR); });
+            }
+        };
+        moveFinish(srcPath, parentFullPath);
     },
 
     tempFileSystem:null,
     persistentFileSystem:null,
     requestFileSystem:function(win,fail,args) {
-		var type = args[0];
-		var size = args[1];
-
-		var filePath = "";
-		var result = null;
-		var fsTypeName = "";
-
-		switch (type) {
-			case LocalFileSystem.TEMPORARY:
-				filePath = FileSystemTemproraryRoot;
-				fsTypeName = "temporary";
-				break;
-			case LocalFileSystem.PERSISTENT:
-				filePath = FileSystemPersistentRoot;
-				fsTypeName = "persistent";
-				break;
-		}
-
-		var MAX_SIZE = 10000000000;
-		if (size > MAX_SIZE) {
-			fail(FileError.QUOTA_EXCEEDED_ERR);
-			return;
-		}
-
-		var fileSystem = new FileSystem(fsTypeName, new DirectoryEntry(fsTypeName, filePath));
-		result = fileSystem;
-    	win(result);
+        var type = args[0];
+        var size = args[1];
+
+        var filePath = "";
+        var result = null;
+        var fsTypeName = "";
+
+        switch (type) {
+            case LocalFileSystem.TEMPORARY:
+                filePath = FileSystemTemproraryRoot;
+                fsTypeName = "temporary";
+                break;
+            case LocalFileSystem.PERSISTENT:
+                filePath = FileSystemPersistentRoot;
+                fsTypeName = "persistent";
+                break;
+        }
+
+        var MAX_SIZE = 10000000000;
+        if (size > MAX_SIZE) {
+            fail(FileError.QUOTA_EXCEEDED_ERR);
+            return;
+        }
+
+        var fileSystem = new FileSystem(fsTypeName, new DirectoryEntry(fsTypeName, filePath));
+        result = fileSystem;
+        win(result);
     },
 
     resolveLocalFileSystemURI:function(win,fail,args) {
-		var uri = args[0];
-
-		var path = uri;
-		path = path.split(" ").join("\ ");
-
-		// support for file name with parameters
-		if (/\?/g.test(path)) {
-			path = String(path).split("\?")[0];
-		};
-
-		// support for encodeURI
-		if (/\%5/g.test(path)) {
-			path = decodeURI(path);
-		};
-
-		// support for special path start with file:///
-		if (path.substr(0, 8) == "file:///") {
-			path = FileSystemPersistentRoot + "\\" + String(path).substr(8).split("/").join("\\");
-			Windows.Storage.StorageFile.getFileFromPathAsync(path).then(
-				function (storageFile) {
-					success(new FileEntry(storageFile.name, storageFile.path));
-				}, function () {
-					Windows.Storage.StorageFolder.getFolderFromPathAsync(path).then(
-						function (storageFolder) {
-							success(new DirectoryEntry(storageFolder.name, storageFolder.path));
-						}, function () {
-							fail(FileError.NOT_FOUND_ERR);
-						}
-					)
-				}
-			)
-		} else {
-			Windows.Storage.StorageFile.getFileFromPathAsync(path).then(
-				function (storageFile) {
-					success(new FileEntry(storageFile.name, storageFile.path));
-				}, function () {
-					Windows.Storage.StorageFolder.getFolderFromPathAsync(path).then(
-						function (storageFolder) {
-							success(new DirectoryEntry(storageFolder.name, storageFolder.path));
-						}, function () {
-							fail(FileError.ENCODING_ERR);
-						}
-					)
-				}
-			)
-    	}
+        var uri = args[0];
+
+        var path = uri;
+        path = path.split(" ").join("\ ");
+
+        // support for file name with parameters
+        if (/\?/g.test(path)) {
+            path = String(path).split("\?")[0];
+        }
+
+        // support for encodeURI
+        if (/\%5/g.test(path)) {
+            path = decodeURI(path);
+        }
+
+        // support for special path start with file:///
+        if (path.substr(0, 8) == "file:///") {
+            path = FileSystemPersistentRoot + "\\" + String(path).substr(8).split("/").join("\\");
+            Windows.Storage.StorageFile.getFileFromPathAsync(path).then(
+                function (storageFile) {
+                    success(new FileEntry(storageFile.name, storageFile.path));
+                }, function () {
+                    Windows.Storage.StorageFolder.getFolderFromPathAsync(path).then(
+                        function (storageFolder) {
+                            success(new DirectoryEntry(storageFolder.name, storageFolder.path));
+                        }, function () {
+                            fail(FileError.NOT_FOUND_ERR);
+                        }
+                    );
+                }
+            );
+        } else {
+            Windows.Storage.StorageFile.getFileFromPathAsync(path).then(
+                function (storageFile) {
+                    success(new FileEntry(storageFile.name, storageFile.path));
+                }, function () {
+                    Windows.Storage.StorageFolder.getFolderFromPathAsync(path).then(
+                        function (storageFolder) {
+                            success(new DirectoryEntry(storageFolder.name, storageFolder.path));
+                        }, function () {
+                            fail(FileError.ENCODING_ERR);
+                        }
+                    );
+                }
+            );
+        }
     }
 
 };
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/ecf62733/lib/windows8/plugin/windows8/FileTransferProxy.js
----------------------------------------------------------------------
diff --git a/lib/windows8/plugin/windows8/FileTransferProxy.js b/lib/windows8/plugin/windows8/FileTransferProxy.js
index 60d7ccd..8556112 100644
--- a/lib/windows8/plugin/windows8/FileTransferProxy.js
+++ b/lib/windows8/plugin/windows8/FileTransferProxy.js
@@ -1,18 +1,18 @@
-´╗┐var FileTransferError = require('cordova/plugin/FileTransferError');
+var FileTransferError = require('cordova/plugin/FileTransferError');
 var FileUploadResult = require('cordova/plugin/FileUploadResult');
 
 module.exports = {
-    
-    upload:function(successCallback, errorCallback, options) {
+
+    upload:function(win, error, options) {
         var filePath = options[0];
         var server = options[1];
 
 
         var win = function (fileUploadResult) {
             successCallback(fileUploadResult);
-        }
+        };
 
-        if (filePath == null || typeof filePath == 'undefined') {
+        if (filePath === null || typeof filePath === 'undefined') {
             error(FileTransferError.FILE_NOT_FOUND_ERR);
             return;
         }
@@ -20,7 +20,7 @@ module.exports = {
         if (String(filePath).substr(0, 8) == "file:///") {
             filePath = FileSystemPersistentRoot + String(filePath).substr(8).split("/").join("\\");
         }
-        
+
         Windows.Storage.StorageFile.getFileFromPathAsync(filePath).then(function (storageFile) {
             storageFile.openAsync(Windows.Storage.FileAccessMode.read).then(function (stream) {
                 var blob = MSApp.createBlobFromRandomAccessStream(storageFile.contentType, stream);
@@ -36,23 +36,23 @@ module.exports = {
                             dataReader.close();
                             win(new FileUploadResult(basicProperties.size, code, fileContent));
 
-                        })
+                        });
 
-                    })
+                    });
                 }, function () {
                     error(FileTransferError.INVALID_URL_ERR);
-                })
-            })
-            
-        },function(){error(FileTransferError.FILE_NOT_FOUND_ERR);})
+                });
+            });
+
+        },function(){error(FileTransferError.FILE_NOT_FOUND_ERR);});
     },
 
-    download:function(successCallback, errorCallback, options) {
+    download:function(win, error, options) {
         var source = options[0];
         var target = options[1];
 
 
-        if (target == null || typeof target == undefined) {
+        if (target === null || typeof target === undefined) {
             error(FileTransferError.FILE_NOT_FOUND_ERR);
             return;
         }
@@ -61,14 +61,14 @@ module.exports = {
         }
         var path = target.substr(0, String(target).lastIndexOf("\\"));
         var fileName = target.substr(String(target).lastIndexOf("\\") + 1);
-        if (path == null || fileName == null) {
+        if (path === null || fileName === null) {
             error(FileTransferError.FILE_NOT_FOUND_ERR);
             return;
         }
 
         var download = null;
-      
-        
+
+
         Windows.Storage.StorageFolder.getFolderFromPathAsync(path).then(function (storageFolder) {
             storageFolder.createFileAsync(fileName, Windows.Storage.CreationCollisionOption.generateUniqueName).then(function (storageFile) {
                 var uri = Windows.Foundation.Uri(source);
@@ -79,9 +79,7 @@ module.exports = {
                 }, function () {
                     error(FileTransferError.INVALID_URL_ERR);
                 });
-            })
-        })
+            });
+        });
     }
-
-    
-}    
+};

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/ecf62733/lib/windows8/plugin/windows8/MediaFile.js
----------------------------------------------------------------------
diff --git a/lib/windows8/plugin/windows8/MediaFile.js b/lib/windows8/plugin/windows8/MediaFile.js
index aa828a1..cebf396 100644
--- a/lib/windows8/plugin/windows8/MediaFile.js
+++ b/lib/windows8/plugin/windows8/MediaFile.js
@@ -1,7 +1,7 @@
 var MediaFileData = require('cordova/plugin/MediaFileData');
 var CaptureError = require('cordova/plugin/CaptureError');
 
-module.exports = {
+module.exports = { // merges with common
 
     getFormatData: function (successCallback, errorCallback, args) {
         Windows.Storage.StorageFile.getFileFromPathAsync(this.fullPath).then(
@@ -14,7 +14,7 @@ module.exports = {
                         }, function () {
                             errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT));
                         }
-                    )
+                    );
                 } else if (mediaTypeFlag === "video") {
                     storageFile.properties.getVideoPropertiesAsync().then(
                         function (videoProperties) {
@@ -22,7 +22,7 @@ module.exports = {
                         }, function () {
                             errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT));
                         }
-                    )
+                    );
                 } else if (mediaTypeFlag === "image") {
                     storageFile.properties.getImagePropertiesAsync().then(
                         function (imageProperties) {
@@ -30,13 +30,13 @@ module.exports = {
                         }, function () {
                             errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT));
                         }
-                    )
+                    );
                 } else {
-                    errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT))
+                    errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT));
                 }
             }, function () {
                 errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT));
             }
-        )
+        );
     }
-}
\ No newline at end of file
+};
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/ecf62733/lib/windows8/plugin/windows8/MediaProxy.js
----------------------------------------------------------------------
diff --git a/lib/windows8/plugin/windows8/MediaProxy.js b/lib/windows8/plugin/windows8/MediaProxy.js
index 39de090..08e1126 100644
--- a/lib/windows8/plugin/windows8/MediaProxy.js
+++ b/lib/windows8/plugin/windows8/MediaProxy.js
@@ -22,7 +22,7 @@ module.exports = {
                 var dur = thisM.node.duration;
                 if (isNaN(dur)) {
                     dur = -1;
-                };
+                }
                 Media.onStatus(id, Media.MEDIA_DURATION, dur);
             } else {
                 lose("Invalid file type");
@@ -50,7 +50,7 @@ module.exports = {
             win();
         } catch (err) {
             lose("Failed to stop: "+err);
-        };
+        }
     },
 
     // Seeks to the postion in the audio
@@ -62,7 +62,7 @@ module.exports = {
             win();
         } catch (err) {
             lose("Failed to seek: "+err);
-        };
+        }
     },
 
     // Pauses the playing audio
@@ -123,7 +123,7 @@ module.exports = {
                 default:
                     lose("Invalid file type for record");
                     break;
-            };
+            }
             thisM.mediaCaptureMgr.startRecordToStorageFileAsync(encodingProfile, storageFile).done(win, lose);
         }, lose);
     },

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/ecf62733/lib/windows8/plugin/windows8/NotificationProxy.js
----------------------------------------------------------------------
diff --git a/lib/windows8/plugin/windows8/NotificationProxy.js b/lib/windows8/plugin/windows8/NotificationProxy.js
index 728fe86..d39c63c 100644
--- a/lib/windows8/plugin/windows8/NotificationProxy.js
+++ b/lib/windows8/plugin/windows8/NotificationProxy.js
@@ -19,15 +19,14 @@ module.exports = {
         var btnList = [];
         function commandHandler (command) {
             win(btnList[command.label]);
-        };
+        }
 
         var md = new Windows.UI.Popups.MessageDialog(message, _title);
         var button = _buttonLabels.split(',');
-        var btnList = [];
         for (var i = 0; i<button.length; i++) {
             btnList[button[i]] = i+1;
             md.commands.append(new Windows.UI.Popups.UICommand(button[i],commandHandler));
-        };
+        }
         md.showAsync();
     },
 

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/ecf62733/lib/windows8/plugin/windows8/geolocation.js
----------------------------------------------------------------------
diff --git a/lib/windows8/plugin/windows8/geolocation.js b/lib/windows8/plugin/windows8/geolocation.js
index 434dcf9..503e049 100644
--- a/lib/windows8/plugin/windows8/geolocation.js
+++ b/lib/windows8/plugin/windows8/geolocation.js
@@ -72,7 +72,7 @@ module.exports = { // Merges with common
 
                 }
             }
-        )
+        );
     },
 
     addWatch:function(win, lose, args) {
@@ -83,7 +83,7 @@ module.exports = { // Merges with common
         // timers[]
         timers[id] = new Windows.Devices.Geolocation.Geolocator().getGeopositionAsync(options.maximumAge, options.timeout).done(
             new Geolocation().getCurrentPosition(win, lose, options)
-        )
+        );
     }
     // clearWatch is not needed as in common code the timer is deleted
 };
\ No newline at end of file


Mime
View raw message