From a5e254350b6f84052b51a9579da938faad60c819 Mon Sep 17 00:00:00 2001 From: HyunJin Park Date: Mon, 14 Sep 2015 18:50:25 +0900 Subject: [PATCH] Revert "Revert "[Filesystem] Fixed for copying, deleting and moving files/dirs."" This reverts commit 0825e63d1a74670485f2b7881882d66a186782ad. Change-Id: I469f3c785ed412f179ca2836abc332d0975807f5 --- src/filesystem/js/common.js | 3 ++- src/filesystem/js/file.js | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/filesystem/js/common.js b/src/filesystem/js/common.js index 38f5a581..1bc8ed30 100755 --- a/src/filesystem/js/common.js +++ b/src/filesystem/js/common.js @@ -218,7 +218,8 @@ var commonFS_ = (function() { } function f_isSubDir(fullPathToCheck, fullPath) { - return (-1 !== fullPathToCheck.indexOf(toRealPath(fullPath))); + var realFullPath = toRealPath(fullPath); + return ((-1 !== fullPathToCheck.indexOf(realFullPath)) && (fullPathToCheck !== realFullPath)); }; function f_isCorrectRelativePath(relativePath) { diff --git a/src/filesystem/js/file.js b/src/filesystem/js/file.js index 8f3e7126..dc68afbc 100755 --- a/src/filesystem/js/file.js +++ b/src/filesystem/js/file.js @@ -726,6 +726,16 @@ File.prototype.deleteDirectory = function(directoryPath, recursive, onsuccess, o } var _myPath = commonFS_.toRealPath(args.directoryPath); + + if (_myPath !== undefined && !commonFS_.f_isSubDir(_myPath, this.fullPath)) { + var m1 = 'Deleted directory should be under the current directory: ' + this.fullPath; + setTimeout(function() { + native_.callIfPossible(args.onerror, + new WebAPIException(WebAPIException.INVALID_VALUES_ERR, m1)); + }, 0); + return; + } + var _result = native_.callSync('File_statSync', {location: _myPath}); if (native_.isFailure(_result)) { setTimeout(function() { -- 2.34.1