[Filesystem] Fix for TCT test.
authorPawel Andruszkiewicz <p.andruszkie@samsung.com>
Wed, 20 May 2015 11:18:26 +0000 (13:18 +0200)
committerHyunjin Park <hj.na.park@samsung.com>
Wed, 3 Jun 2015 02:29:55 +0000 (11:29 +0900)
Resolve should report InvalidValuesError if application does not have access to a file/directory.

[Verification] FileSystemManager_resolve_wgt_package_of_another_app passes.

Change-Id: I9ccc2dd0dea6775f769e8f9f2ad50a6427a0622a
Signed-off-by: Pawel Andruszkiewicz <p.andruszkie@samsung.com>
src/filesystem/filesystem_instance.cc
src/filesystem/filesystem_manager.cc
src/filesystem/filesystem_stat.cc
src/filesystem/filesystem_stat.h
src/filesystem/filesystem_utils.h

index a41763109d32eef526d862b3d4f67270af98ebf1..d2154598f46fe0745530a45bd20168bf4e20d73a 100755 (executable)
@@ -615,6 +615,9 @@ void FilesystemInstance::PrepareError(const FilesystemError& error, picojson::ob
     case FilesystemError::Other:
       ReportError(UnknownException("PLATFORM ERROR"), out);
       break;
+    case FilesystemError::InvalidValue:
+      ReportError(InvalidValuesException("PLATFORM ERROR"), out);
+      break;
     default:
       ReportError(UnknownException("PLATFORM ERROR"), out);
       break;
index 3c5d997ac7770e61e241149cb537c463daeb03a6..a9cdf9cc391ff3a56a94b0cbe490e24b58073c06 100755 (executable)
@@ -243,7 +243,7 @@ void FilesystemManager::StatPath(
   LoggerD("enter");
   FilesystemStat statData = FilesystemStat::getStat(path);
   if (!statData.valid) {
-    error_cb(FilesystemError::NotFound);
+    error_cb(statData.error);
     return;
   }
 
index a407fcc1731ad6d92a67bc38aad83995de271c83..520c12f5352bb9b53c8792d9ba0d244c0da47a3e 100755 (executable)
@@ -26,7 +26,7 @@
 namespace extension {
 namespace filesystem {
 
-FilesystemStat::FilesystemStat() : valid(false) {}
+FilesystemStat::FilesystemStat() : error(FilesystemError::None), valid(false) {}
 
 picojson::value FilesystemStat::toJSON() const {
   LoggerD("Enter");
@@ -48,14 +48,20 @@ picojson::value FilesystemStat::toJSON() const {
 FilesystemStat FilesystemStat::getStat(const std::string& path) {
   LoggerD("Enter");
   struct stat aStatObj;
+  FilesystemStat _result;
+
   LoggerD("enter");
+
   if (0 != stat(path.c_str(), &aStatObj)) {
     LoggerE("Failed to stat: (%d) %s", errno, strerror(errno));
-    return FilesystemStat();
+    if (ENOENT == errno) {
+      _result.error = FilesystemError::NotFound;
+    } else {
+      _result.error = FilesystemError::InvalidValue;
+    }
+    return _result;
   }
 
-  FilesystemStat _result;
-
   _result.path = path;
   _result.readOnly = true;
   if (getuid() == aStatObj.st_uid && (aStatObj.st_mode & S_IWUSR) == S_IWUSR) {
index 78f38521a015278acc50f24f30337cd85aba8f79..62b78373484354e87f59af3dcfaa809e11dcd0b9 100755 (executable)
 #define FILESYSTEM_FILESYSTEM_STAT_H
 
 #include <string>
-#include <common/picojson.h>
+
+#include "common/picojson.h"
+
+#include "filesystem/filesystem_utils.h"
 
 namespace extension {
 namespace filesystem {
@@ -26,6 +29,7 @@ class FilesystemStat {
   FilesystemStat();
 
  public:
+  FilesystemError error;
   bool valid;
 
   std::string path;
index 343bc5a992eacc759843439f192f1d7c7b5ee7e3..3522c59ccf93803ed3db03126698b80c591ccba9 100755 (executable)
@@ -31,6 +31,7 @@ enum class FilesystemError {
   DirectoryExists,
   PermissionDenied,
   IOError,
+  InvalidValue,
   Other
 };
 }  // namespace filesystem