From: taekeun.kang Date: Wed, 21 Oct 2015 01:26:48 +0000 (+0900) Subject: Revert "[Filesystem] sync tizen_2.4 branch latest filesystem source code." X-Git-Tag: submit/tizen/20151026.073646^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a0c27b0d7f21aa11e6207f4ba24d80f5c6186b87;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git Revert "[Filesystem] sync tizen_2.4 branch latest filesystem source code." This reverts commit e664b9819758fed1a213dcb9bf83f51d2b59dfaa. Change-Id: I4930e8196648dd3538fc670515c8335e9601427b Signed-off-by: taekeun.kang --- diff --git a/src/common/current_application.cc b/src/common/current_application.cc index 85910ccf..fc08be08 100755 --- a/src/common/current_application.cc +++ b/src/common/current_application.cc @@ -62,7 +62,7 @@ std::string CurrentApplication::FetchApplicationId() const { if ((APP_MANAGER_ERROR_NONE == ret) && (nullptr != tmp_str)) { app_id = tmp_str; } else { - LoggerE("Failed to get application ID: %d (%s)", ret, get_error_message(ret)); + LoggerE("Failed to get application ID."); } free(tmp_str); @@ -81,7 +81,7 @@ std::string CurrentApplication::FetchPackageId() const { if ((PACKAGE_MANAGER_ERROR_NONE == ret) && (nullptr != tmp_str)) { package_id = tmp_str; } else { - LoggerE("Can't get package name from app info: %d (%s)", ret, get_error_message(ret)); + LoggerE("Failed to get package ID."); } free(tmp_str); diff --git a/src/common/virtual_fs.cc b/src/common/virtual_fs.cc index 01991b1f..78d5f9d3 100755 --- a/src/common/virtual_fs.cc +++ b/src/common/virtual_fs.cc @@ -94,8 +94,7 @@ common::optional GetRootDir() { app_info_h app_info; int err = app_info_create(app_id.c_str(), &app_info); if (APP_MANAGER_ERROR_NONE != err) { - LoggerE("Can't create app info handle from appId (%s): %d (%s)", app_id.c_str(), err, - get_error_message(err)); + LoggerE("Can't create app info handle from appId (%s)", app_id.c_str()); return nullptr; } SCOPE_EXIT { @@ -233,8 +232,8 @@ VirtualFs::VirtualFs() : app_root_(GetRootDir()) { int err = storage_foreach_device_supported(OnStorageDeviceSupported, nullptr); - if (STORAGE_ERROR_NONE != err) { - LoggerE("Unknown Error on getting storage paths %d (%s)", err, get_error_message(err)); + if (err != STORAGE_ERROR_NONE) { + LoggerE("Unknown Error on getting storage paths"); } int id = -1; diff --git a/src/filesystem/filesystem_instance.cc b/src/filesystem/filesystem_instance.cc index 93ceb1d7..5e4d10b9 100755 --- a/src/filesystem/filesystem_instance.cc +++ b/src/filesystem/filesystem_instance.cc @@ -597,40 +597,31 @@ void FilesystemInstance::PrepareError(const FilesystemError& error, picojson::ob LoggerD("enter"); switch (error) { case FilesystemError::None: - LoggerE("UnknownException - PLATFORM ERROR"); ReportError(UnknownException("PLATFORM ERROR"), out); break; case FilesystemError::NotFound: - LoggerE("NotFoundException - PLATFORM ERROR"); ReportError(NotFoundException("PLATFORM ERROR"), out); break; case FilesystemError::FileExists: - LoggerE("IOException - File already exists"); ReportError(IOException("File already exists"), out); break; case FilesystemError::DirectoryExists: - LoggerE("IOException - Directory already exists"); ReportError(IOException("Directory already exists"), out); break; case FilesystemError::PermissionDenied: - LoggerE("IOException - Permission denied"); ReportError(IOException("Permission denied"), out); break; case FilesystemError::IOError: - LoggerE("IOException - IO Error"); ReportError(IOException("IO Error"), out); break; case FilesystemError::Other: - LoggerE("UnknownException - PLATFORM ERROR other"); - ReportError(UnknownException("PLATFORM ERROR other"), out); + ReportError(UnknownException("PLATFORM ERROR"), out); break; case FilesystemError::InvalidValue: - LoggerE("InvalidValuesException - PLATFORM ERROR"); ReportError(InvalidValuesException("PLATFORM ERROR"), out); break; default: - LoggerE("UnknownException - PLATFORM ERROR default"); - ReportError(UnknownException("PLATFORM ERROR default"), out); + ReportError(UnknownException("PLATFORM ERROR"), out); break; } } diff --git a/src/filesystem/filesystem_utils.cc b/src/filesystem/filesystem_utils.cc index 6fd4fcdc..c2889350 100755 --- a/src/filesystem/filesystem_utils.cc +++ b/src/filesystem/filesystem_utils.cc @@ -22,11 +22,11 @@ namespace FilesystemUtils { std::string get_storage_dir_path(int id, storage_directory_e typeToCheck) { LoggerD("Enter"); + int result = STORAGE_ERROR_NONE; char* platformPath = NULL; - int result = storage_get_directory(id, typeToCheck, &platformPath); - if (STORAGE_ERROR_NONE != result) { - LoggerE("Cannot retrieve path for type %i: %d (%s)", typeToCheck, result, - get_error_message(result)); + result = storage_get_directory(id, typeToCheck, &platformPath); + if (result != STORAGE_ERROR_NONE) { + LoggerD("Cannot retrieve path for type %i", typeToCheck); return std::string(); } std::string path = std::string(platformPath); diff --git a/src/filesystem/js/common.js b/src/filesystem/js/common.js index 1bc8ed30..ed45ada6 100755 --- a/src/filesystem/js/common.js +++ b/src/filesystem/js/common.js @@ -218,13 +218,12 @@ var commonFS_ = (function() { } function f_isSubDir(fullPathToCheck, fullPath) { - var realFullPath = toRealPath(fullPath); - return ((-1 !== fullPathToCheck.indexOf(realFullPath)) && (fullPathToCheck !== realFullPath)); + return (-1 !== fullPathToCheck.indexOf(toRealPath(fullPath))); }; function f_isCorrectRelativePath(relativePath) { - return ((0 !== relativePath.indexOf('/')) && - (0 !== relativePath.indexOf('\\')) && + return ((-1 === relativePath.indexOf('/')) && + (-1 === relativePath.indexOf('\\')) && (-1 === relativePath.indexOf('?')) && (-1 === relativePath.indexOf('*')) && (-1 === relativePath.indexOf(':')) && @@ -261,7 +260,6 @@ var commonFS_ = (function() { } return { - clearCache: clearCache, toRealPath: toRealPath, toVirtualPath: toVirtualPath, getFileInfo: getFileInfo, diff --git a/src/filesystem/js/file.js b/src/filesystem/js/file.js index 278fdf60..c7d80b18 100755 --- a/src/filesystem/js/file.js +++ b/src/filesystem/js/file.js @@ -365,6 +365,15 @@ File.prototype.copyTo = function(originFilePath, destinationFilePath, overwrite, return; } + var lastChar; + var addFilenameToPath = false; + if (args.destinationFilePath.length) { + lastChar = args.destinationFilePath.substr(args.destinationFilePath.length - 1); + if (lastChar === '/') { + addFilenameToPath = true; + } + } + var _realOriginalPath = commonFS_.toRealPath(args.originFilePath); var _realDestinationPath = commonFS_.toRealPath(args.destinationFilePath); @@ -395,45 +404,13 @@ File.prototype.copyTo = function(originFilePath, destinationFilePath, overwrite, } var _oldNode = native_.getResultObject(resultOldPath); - var addFileName = false; - var lastChar = _realDestinationPath.substr(_realDestinationPath.length -1); - - var resultNewPath = native_.callSync('File_statSync', {location: _realDestinationPath}); - if (native_.isSuccess(resultNewPath)) { - var _newNode = native_.getResultObject(resultNewPath); - if (_newNode.isDirectory) { - if (lastChar !== '/') { - _realDestinationPath += '/'; - } - addFileName = true; - } - } else { - var destinationFileName, destinationDirectoryPath; - if (lastChar !== '/') { - destinationFileName = _realDestinationPath.split('/').pop(); - } - destinationDirectoryPath = _realDestinationPath.substr(0, _realDestinationPath.lastIndexOf('/') + 1); - - var resultDestinationDirectory = native_.callSync('File_statSync', {location: destinationDirectoryPath}); - if (native_.isFailure(resultDestinationDirectory)) { - setTimeout(function() { - native_.callIfPossible(args.onerror, native_.getErrorObject(resultDestinationDirectory)); - }, 0); - return; - } - - if (destinationFileName.length == 0) { - addFileName = true; - } - } - - if (_oldNode.isFile && addFileName) { - _realDestinationPath += _realOriginalPath.split('/').pop(); + if (_oldNode.isFile && addFilenameToPath) { + _realDestinationPath = _realDestinationPath + _realOriginalPath.split('/').pop(); } if (!args.overwrite) { - var resultPath = native_.callSync('File_statSync', {location: _realDestinationPath}); - if (native_.isSuccess(resultPath)) { + var resultNewPath = native_.callSync('File_statSync', {location: _realDestinationPath}); + if (native_.isSuccess(resultNewPath)) { setTimeout(function() { native_.callIfPossible(args.onerror, new WebAPIException(WebAPIException.IO_ERR, 'Overwrite is not allowed')); @@ -751,16 +728,6 @@ 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() { diff --git a/src/filesystem/js/file_system_manager.js b/src/filesystem/js/file_system_manager.js index 6f24d906..e5e3c8b8 100755 --- a/src/filesystem/js/file_system_manager.js +++ b/src/filesystem/js/file_system_manager.js @@ -160,7 +160,6 @@ function nextCallbackId() { } function _StorageStateChangeListener(result) { - commonFS_.clearCache(); var storage = new FileSystemStorage(result); for (var id in callbacks) { native_.callIfPossible(callbacks[id], storage);