mirror of
https://github.com/sebastiandine/Card-Collection-Manager-3.git
synced 2026-08-28 17:01:02 +00:00
55ace147bc
* initial development * pipeline * pipeline * pipeline * pipeline * pipeline * pipeline * pipeline * pipeline * pipeline * pipeline * pipeline * pipeline * pipeline * pipeline * ci/cd * ci/cd * ci/cd * ci/cd * ci/cd * ci/cd * ci/cd * pokemon * pokemon * pokemon * pokemon * pokemon * pokemon * improvements * improvements * ci/cd * ci/cd * improvements * improvements * improvements * improvements * improvements * improvements * improvements * improvements * improvements --------- Co-authored-by: sdine <sdine@sdine.com>
34 lines
1.2 KiB
C++
34 lines
1.2 KiB
C++
#pragma once
|
|
|
|
// IFileSystem - filesystem operations the services need, expressed as a
|
|
// narrow port. Real implementation is `StdFileSystem` (over <filesystem>).
|
|
// In-memory implementation can be plugged in for tests.
|
|
|
|
#include "ccm/util/Result.hpp"
|
|
|
|
#include <filesystem>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace ccm {
|
|
|
|
class IFileSystem {
|
|
public:
|
|
virtual ~IFileSystem() = default;
|
|
|
|
[[nodiscard]] virtual bool exists(const std::filesystem::path& p) const = 0;
|
|
[[nodiscard]] virtual bool isDirectory(const std::filesystem::path& p) const = 0;
|
|
|
|
virtual Result<void> ensureDirectory(const std::filesystem::path& p) = 0;
|
|
virtual Result<std::string> readText(const std::filesystem::path& p) = 0;
|
|
virtual Result<void> writeText(const std::filesystem::path& p, std::string_view contents) = 0;
|
|
virtual Result<void> copyFile(const std::filesystem::path& from,
|
|
const std::filesystem::path& to,
|
|
bool overwrite) = 0;
|
|
virtual Result<void> remove(const std::filesystem::path& p) = 0;
|
|
virtual Result<std::vector<std::filesystem::path>> listDirectory(
|
|
const std::filesystem::path& p) = 0;
|
|
};
|
|
|
|
} // namespace ccm
|