Revert "[Filesystem] sync tizen_2.4 branch latest filesystem source code."
authortaekeun.kang <taekeun.kang@samsung.com>
Wed, 21 Oct 2015 01:26:48 +0000 (10:26 +0900)
committertaekeun.kang <taekeun.kang@samsung.com>
Wed, 21 Oct 2015 01:27:49 +0000 (10:27 +0900)
This reverts commit e664b9819758fed1a213dcb9bf83f51d2b59dfaa.

Change-Id: I4930e8196648dd3538fc670515c8335e9601427b
Signed-off-by: taekeun.kang <taekeun.kang@samsung.com>
src/common/current_application.cc
src/common/virtual_fs.cc
src/filesystem/filesystem_instance.cc
src/filesystem/filesystem_utils.cc
src/filesystem/js/common.js
src/filesystem/js/file.js
src/filesystem/js/file_system_manager.js

index 85910cc..fc08be0 100755 (executable)
@@ -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);
index 01991b1..78d5f9d 100755 (executable)
@@ -94,8 +94,7 @@ common::optional<std::string> 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;
index 93ceb1d..5e4d10b 100755 (executable)
@@ -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;
   }
 }
index 6fd4fcd..c288935 100755 (executable)
 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);
index 1bc8ed3..ed45ada 100755 (executable)
@@ -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,
index 278fdf6..c7d80b1 100755 (executable)
@@ -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() {
index 6f24d90..e5e3c8b 100755 (executable)
@@ -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);