[ox/fs] Wrap overloaded virtual functions in FileSystem

This commit is contained in:
2023-01-27 00:00:35 -06:00
parent 94cb2e982a
commit 1cfa594c92
6 changed files with 225 additions and 167 deletions

View File

@ -11,7 +11,6 @@
#if __has_include(<filesystem>) && defined(OX_USE_STDLIB)
#include <filesystem>
#include <string>
#include <ox/std/bit.hpp>
#include "filesystem.hpp"
@ -37,36 +36,22 @@ class PassThroughFS: public FileSystem {
[[nodiscard]]
String basePath() const noexcept;
Error mkdir(CRStringView path, bool recursive = false) noexcept override;
Error mkdir(CRStringView path, bool recursive) noexcept override;
Error move(CRStringView src, CRStringView dest) noexcept override;
Error read(CRStringView path, void *buffer, std::size_t buffSize) noexcept override;
Result<const char*> directAccess(CRStringView) noexcept override;
Error read(uint64_t inode, void *buffer, std::size_t size) noexcept override;
Error read(uint64_t inode, std::size_t readStart, std::size_t readSize, void *buffer, std::size_t *size) noexcept override;
Result<const char*> directAccess(uint64_t) noexcept override;
Result<Vector<String>> ls(CRStringView dir) const noexcept override;
template<typename F>
Error ls(CRStringView dir, F cb) const noexcept;
Error remove(CRStringView path, bool recursive = false) noexcept override;
Error remove(CRStringView path, bool recursive) noexcept override;
Error resize(uint64_t size, void *buffer = nullptr) noexcept override;
Error resize(uint64_t size, void *buffer) noexcept override;
Error write(CRStringView path, const void *buffer, uint64_t size, FileType fileType = FileType::NormalFile) noexcept override;
Result<FileStat> statInode(uint64_t inode) const noexcept override;
Error write(uint64_t inode, const void *buffer, uint64_t size, FileType fileType = FileType::NormalFile) noexcept override;
Result<FileStat> stat(uint64_t inode) const noexcept override;
Result<FileStat> stat(CRStringView path) const noexcept override;
Result<FileStat> statPath(CRStringView path) const noexcept override;
[[nodiscard]]
uint64_t spaceNeeded(uint64_t size) const noexcept override;
@ -83,6 +68,17 @@ class PassThroughFS: public FileSystem {
[[nodiscard]]
bool valid() const noexcept override;
protected:
Error readFilePath(CRStringView path, void *buffer, std::size_t buffSize) noexcept override;
Error readFileInode(uint64_t inode, void *buffer, std::size_t size) noexcept override;
Error readFileInodeRange(uint64_t inode, std::size_t readStart, std::size_t readSize, void *buffer, std::size_t *size) noexcept override;
Error writeFilePath(CRStringView path, const void *buffer, uint64_t size, FileType fileType) noexcept override;
Error writeFileInode(uint64_t inode, const void *buffer, uint64_t size, FileType fileType) noexcept override;
private:
/**
* Strips the leading slashes from a string.