Added MappingFileSystemAdapter and adjusted some more stuff in the VFS module.
This commit is contained in:
@@ -79,7 +79,6 @@ class FileSystemAdapter
|
||||
public:
|
||||
virtual ~FileSystemAdapter() = default;
|
||||
|
||||
[[nodiscard]] virtual std::vector<fs::path> getRoots() = 0;
|
||||
[[nodiscard]] virtual fs::path getHomeFolder() = 0;
|
||||
[[nodiscard]] virtual std::vector<FileInfo> listFiles(const fs::path& folder) = 0;
|
||||
[[nodiscard]] virtual FileInfo getFileInfo(const fs::path& file) = 0;
|
||||
@@ -92,7 +91,6 @@ public:
|
||||
class OSFileSystemAdapter : public FileSystemAdapter
|
||||
{
|
||||
public:
|
||||
std::vector<fs::path> getRoots() override;
|
||||
fs::path getHomeFolder() override;
|
||||
std::vector<FileInfo> listFiles(const fs::path& folder) override;
|
||||
FileInfo getFileInfo(const fs::path& file) override;
|
||||
@@ -153,6 +151,30 @@ inline std::string formatFileSize(std::size_t sizeInBytes)
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
namespace vfs_pipe
|
||||
{
|
||||
template<typename TReal, typename TAdapter = FileSystemAdapter>
|
||||
struct Builder
|
||||
{
|
||||
using adapter_t = TAdapter;
|
||||
|
||||
operator std::unique_ptr<FileSystemAdapter>()
|
||||
{
|
||||
return static_cast<TReal&>(*this).build();
|
||||
}
|
||||
};
|
||||
|
||||
struct OSBuilder : Builder<OSBuilder, OSFileSystemAdapter>
|
||||
{
|
||||
std::unique_ptr<OSFileSystemAdapter> build()
|
||||
{
|
||||
return std::make_unique<OSFileSystemAdapter>();
|
||||
}
|
||||
};
|
||||
|
||||
[[nodiscard]]
|
||||
inline OSBuilder os() noexcept { return {}; }
|
||||
}
|
||||
} // namespace mijin
|
||||
|
||||
template<>
|
||||
|
||||
Reference in New Issue
Block a user