| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | // Copyright 2019 Juan Palacios <[email protected]> |
| 3 | |
| 4 | #pragma once |
| 5 | |
| 6 | #include "ifilecache.h" |
| 7 | #include <filesystem> |
| 8 | |
| 9 | class FileCache : public IFileCache |
| 10 | { |
| 11 | public: |
| 12 | FileCache(std::filesystem::path &&path) noexcept; |
| 13 | |
| 14 | void init() override; |
| 15 | std::optional<std::filesystem::path> add(std::filesystem::path const &path, |
| 16 | std::string const &name) override; |
| 17 | std::optional<std::filesystem::path> add(std::vector<char> const &data, |
| 18 | std::string const &name) override; |
| 19 | void remove(std::string const &name) override; |
| 20 | std::optional<std::filesystem::path> |
| 21 | get(std::string const &name, |
| 22 | std::filesystem::path const &defaultPath) const override; |
| 23 | std::filesystem::path path() const override; |
| 24 | |
| 25 | private: |
| 26 | bool cacheDirectoryExist() const; |
| 27 | |
| 28 | std::filesystem::path const path_; |
| 29 | }; |