Krzysztof Grobelny | 73da690 | 2020-09-24 13:42:04 +0200 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include "interfaces/json_storage.hpp" |
| 4 | |
| 5 | class PersistentJsonStorage : public interfaces::JsonStorage |
| 6 | { |
| 7 | public: |
| 8 | explicit PersistentJsonStorage(const DirectoryPath& directory); |
| 9 | |
| 10 | void store(const FilePath& subPath, const nlohmann::json& data) override; |
| 11 | bool remove(const FilePath& subPath) override; |
| 12 | std::optional<nlohmann::json> load(const FilePath& subPath) const override; |
| 13 | std::vector<FilePath> |
| 14 | list(const DirectoryPath& subDirectory) const override; |
| 15 | |
| 16 | private: |
| 17 | DirectoryPath directory; |
| 18 | |
| 19 | static std::filesystem::path join(const std::filesystem::path&, |
| 20 | const std::filesystem::path&); |
| 21 | static void limitPermissions(const std::filesystem::path& path); |
| 22 | }; |