#include "common/filesystem/filesystem_provider.h"
#include "common/logger.h"
#include "common/picojson.h"
+#include "common/scope_exit.h"
#include "common/task-queue.h"
#include "common/tools.h"
// other values (not specified in the documentation) are handled in JS
switch (ret) {
- case SYSTEM_SETTINGS_ERROR_NONE:
+ case SYSTEM_SETTINGS_ERROR_NONE: {
+ SCOPE_EXIT {
+ free(value);
+ };
LoggerD("ret == SYSTEM_SETTINGS_ERROR_NONE");
+ CHECK_STORAGE_ACCESS_AND_RETURN(value);
result_obj.insert(std::make_pair("value", picojson::value(value ? value : "")));
- free(value);
return PlatformResult(ErrorCode::NO_ERROR);
+ }
case SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED:
return LogAndCreateResult(
ErrorCode::NOT_SUPPORTED_ERR, "This property is not supported.",
const std::string& value = args.get("value").get<std::string>();
LoggerD("Value to set: %s ", value.c_str());
- auto get = [this, type, value,
+ std::string real_path = common::FilesystemProvider::Create().GetRealPath(value);
+ CHECK_STORAGE_ACCESS(real_path, &out);
+
+ auto get = [this, type, real_path,
callback_id](const std::shared_ptr<picojson::value>& response) -> void {
ScopeLogger("Entered into asynchronous function, get");
- std::string real_path = common::FilesystemProvider::Create().GetRealPath(value);
PlatformResult status = setPlatformPropertyValue(type, real_path);
picojson::object& obj = response->get<picojson::object>();
if (status.IsSuccess()) {