Added PersistentJsonStorageClass
PersistentJsonStorage is used to store persistent information in
json format. This class will be used by ReportManager to save
persistent report configuration.
Tested:
- Added unit tests for new functionality
- All other unit tests are passing
Signed-off-by: Krzysztof Grobelny <krzysztof.grobelny@intel.com>
Change-Id: Ib496e6782e849d910fe37c02c355047afda5c79c
diff --git a/src/persistent_json_storage.hpp b/src/persistent_json_storage.hpp
new file mode 100644
index 0000000..4b18aa1
--- /dev/null
+++ b/src/persistent_json_storage.hpp
@@ -0,0 +1,22 @@
+#pragma once
+
+#include "interfaces/json_storage.hpp"
+
+class PersistentJsonStorage : public interfaces::JsonStorage
+{
+ public:
+ explicit PersistentJsonStorage(const DirectoryPath& directory);
+
+ void store(const FilePath& subPath, const nlohmann::json& data) override;
+ bool remove(const FilePath& subPath) override;
+ std::optional<nlohmann::json> load(const FilePath& subPath) const override;
+ std::vector<FilePath>
+ list(const DirectoryPath& subDirectory) const override;
+
+ private:
+ DirectoryPath directory;
+
+ static std::filesystem::path join(const std::filesystem::path&,
+ const std::filesystem::path&);
+ static void limitPermissions(const std::filesystem::path& path);
+};