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;
namespace extension {
namespace filesystem {
-FilesystemStat::FilesystemStat() : valid(false) {}
+FilesystemStat::FilesystemStat() : error(FilesystemError::None), valid(false) {}
picojson::value FilesystemStat::toJSON() const {
picojson::value retval = picojson::value(picojson::object());
FilesystemStat FilesystemStat::getStat(const std::string& path) {
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) {
#define FILESYSTEM_FILESYSTEM_STAT_H
#include <string>
-#include <common/picojson.h>
+
+#include "common/picojson.h"
+
+#include "filesystem/filesystem_utils.h"
namespace extension {
namespace filesystem {
FilesystemStat();
public:
+ FilesystemError error;
bool valid;
std::string path;