173da6906SKrzysztof Grobelny #pragma once 273da6906SKrzysztof Grobelny 373da6906SKrzysztof Grobelny #include "interfaces/json_storage.hpp" 473da6906SKrzysztof Grobelny 573da6906SKrzysztof Grobelny class PersistentJsonStorage : public interfaces::JsonStorage 673da6906SKrzysztof Grobelny { 773da6906SKrzysztof Grobelny public: 873da6906SKrzysztof Grobelny explicit PersistentJsonStorage(const DirectoryPath& directory); 973da6906SKrzysztof Grobelny 1073da6906SKrzysztof Grobelny void store(const FilePath& subPath, const nlohmann::json& data) override; 1173da6906SKrzysztof Grobelny bool remove(const FilePath& subPath) override; 12e2362796SWludzik, Jozef bool exist(const FilePath& path) const override; 1373da6906SKrzysztof Grobelny std::optional<nlohmann::json> load(const FilePath& subPath) const override; 14e2362796SWludzik, Jozef std::vector<FilePath> list() const override; 1573da6906SKrzysztof Grobelny 1673da6906SKrzysztof Grobelny private: 1773da6906SKrzysztof Grobelny DirectoryPath directory; 1873da6906SKrzysztof Grobelny 1973da6906SKrzysztof Grobelny static std::filesystem::path join(const std::filesystem::path&, 2073da6906SKrzysztof Grobelny const std::filesystem::path&); 2173da6906SKrzysztof Grobelny static void limitPermissions(const std::filesystem::path& path); 22*a06626d1SKrzysztof Grobelny static void assertThatPathIsNotSymlink(const std::filesystem::path& path); 2373da6906SKrzysztof Grobelny }; 24