[ox/fs] Enforce error checking of FS function calls
This commit is contained in:
parent
6a5b16c644
commit
74fe0c55cc
@ -77,21 +77,21 @@ class FileStoreTemplate {
|
||||
|
||||
FileStoreTemplate(void *buff, size_t buffSize);
|
||||
|
||||
static Error format(void *buffer, size_t bufferSize);
|
||||
[[nodiscard]] static Error format(void *buffer, size_t bufferSize);
|
||||
|
||||
Error setSize(InodeId_t buffSize);
|
||||
[[nodiscard]] Error setSize(InodeId_t buffSize);
|
||||
|
||||
Error incLinks(InodeId_t id);
|
||||
[[nodiscard]] Error incLinks(InodeId_t id);
|
||||
|
||||
Error decLinks(InodeId_t id);
|
||||
[[nodiscard]] Error decLinks(InodeId_t id);
|
||||
|
||||
Error write(InodeId_t id, void *data, FsSize_t dataLen, uint8_t fileType = 0);
|
||||
[[nodiscard]] Error write(InodeId_t id, void *data, FsSize_t dataLen, uint8_t fileType = 0);
|
||||
|
||||
Error remove(InodeId_t id);
|
||||
[[nodiscard]] Error remove(InodeId_t id);
|
||||
|
||||
Error read(InodeId_t id, void *data, FsSize_t dataSize, FsSize_t *size = nullptr) const;
|
||||
[[nodiscard]] Error read(InodeId_t id, void *data, FsSize_t dataSize, FsSize_t *size = nullptr) const;
|
||||
|
||||
Error read(InodeId_t id, FsSize_t readStart, FsSize_t readSize, void *data, FsSize_t *size = nullptr) const;
|
||||
[[nodiscard]] Error read(InodeId_t id, FsSize_t readStart, FsSize_t readSize, void *data, FsSize_t *size = nullptr) const;
|
||||
|
||||
const ptrarith::Ptr<uint8_t, std::size_t> read(InodeId_t id) const;
|
||||
|
||||
@ -106,21 +106,21 @@ class FileStoreTemplate {
|
||||
* @return 0 if read is a success
|
||||
*/
|
||||
template<typename T>
|
||||
Error read(InodeId_t id, FsSize_t readStart,
|
||||
[[nodiscard]] Error read(InodeId_t id, FsSize_t readStart,
|
||||
FsSize_t readSize, T *data,
|
||||
FsSize_t *size) const;
|
||||
|
||||
ValErr<StatInfo> stat(InodeId_t id);
|
||||
[[nodiscard]] ValErr<StatInfo> stat(InodeId_t id);
|
||||
|
||||
Error resize(std::size_t size, void *newBuff = nullptr);
|
||||
[[nodiscard]] Error resize(std::size_t size, void *newBuff = nullptr);
|
||||
|
||||
InodeId_t spaceNeeded(FsSize_t size);
|
||||
[[nodiscard]] InodeId_t spaceNeeded(FsSize_t size);
|
||||
|
||||
InodeId_t size() const;
|
||||
[[nodiscard]] InodeId_t size() const;
|
||||
|
||||
InodeId_t available();
|
||||
[[nodiscard]] InodeId_t available();
|
||||
|
||||
uint8_t *buff();
|
||||
[[nodiscard]] uint8_t *buff();
|
||||
|
||||
Error walk(Error(*cb)(uint8_t, uint64_t, uint64_t));
|
||||
|
||||
|
26
deps/ox/src/ox/fs/filesystem/directory.hpp
vendored
26
deps/ox/src/ox/fs/filesystem/directory.hpp
vendored
@ -45,7 +45,7 @@ struct __attribute__((packed)) DirectoryEntry {
|
||||
init(inode, name, bufferSize);
|
||||
}
|
||||
|
||||
Error init(InodeId_t inode, const char *name, InodeId_t bufferSize) {
|
||||
ox::Error init(InodeId_t inode, const char *name, InodeId_t bufferSize) {
|
||||
m_bufferSize = bufferSize;
|
||||
auto d = data();
|
||||
if (d.valid()) {
|
||||
@ -101,23 +101,23 @@ class Directory {
|
||||
/**
|
||||
* Initializes Directory.
|
||||
*/
|
||||
Error init() noexcept;
|
||||
[[nodiscard]] ox::Error init() noexcept;
|
||||
|
||||
Error mkdir(PathIterator path, bool parents, FileName *nameBuff = nullptr);
|
||||
[[nodiscard]] ox::Error mkdir(PathIterator path, bool parents, FileName *nameBuff = nullptr);
|
||||
|
||||
/**
|
||||
* @param parents indicates the operation should create non-existent directories in the path, like mkdir -p
|
||||
*/
|
||||
Error write(PathIterator it, InodeId_t inode, FileName *nameBuff = nullptr) noexcept;
|
||||
[[nodiscard]] ox::Error write(PathIterator it, InodeId_t inode, FileName *nameBuff = nullptr) noexcept;
|
||||
|
||||
Error remove(PathIterator it, FileName *nameBuff = nullptr) noexcept;
|
||||
[[nodiscard]] ox::Error remove(PathIterator it, FileName *nameBuff = nullptr) noexcept;
|
||||
|
||||
template<typename F>
|
||||
Error ls(F cb) noexcept;
|
||||
[[nodiscard]] ox::Error ls(F cb) noexcept;
|
||||
|
||||
ValErr<typename FileStore::InodeId_t> findEntry(const FileName &name) const noexcept;
|
||||
[[nodiscard]] ValErr<typename FileStore::InodeId_t> findEntry(const FileName &name) const noexcept;
|
||||
|
||||
ValErr<typename FileStore::InodeId_t> find(PathIterator name, FileName *nameBuff = nullptr) const noexcept;
|
||||
[[nodiscard]] ValErr<typename FileStore::InodeId_t> find(PathIterator name, FileName *nameBuff = nullptr) const noexcept;
|
||||
|
||||
};
|
||||
|
||||
@ -132,7 +132,7 @@ Directory<FileStore, InodeId_t>::Directory(FileStore fs, InodeId_t inodeId) {
|
||||
}
|
||||
|
||||
template<typename FileStore, typename InodeId_t>
|
||||
Error Directory<FileStore, InodeId_t>::init() noexcept {
|
||||
ox::Error Directory<FileStore, InodeId_t>::init() noexcept {
|
||||
constexpr auto Size = sizeof(Buffer);
|
||||
oxReturnError(m_fs.write(m_inodeId, nullptr, Size));
|
||||
auto buff = m_fs.read(m_inodeId);
|
||||
@ -146,7 +146,7 @@ Error Directory<FileStore, InodeId_t>::init() noexcept {
|
||||
}
|
||||
|
||||
template<typename FileStore, typename InodeId_t>
|
||||
Error Directory<FileStore, InodeId_t>::mkdir(PathIterator path, bool parents, FileName *nameBuff) {
|
||||
ox::Error Directory<FileStore, InodeId_t>::mkdir(PathIterator path, bool parents, FileName *nameBuff) {
|
||||
if (path.valid()) {
|
||||
oxTrace("ox::fs::Directory::mkdir") << path.fullPath();
|
||||
// reuse nameBuff if it has already been allocated, as it is a rather large variable
|
||||
@ -190,7 +190,7 @@ Error Directory<FileStore, InodeId_t>::mkdir(PathIterator path, bool parents, Fi
|
||||
}
|
||||
|
||||
template<typename FileStore, typename InodeId_t>
|
||||
Error Directory<FileStore, InodeId_t>::write(PathIterator path, InodeId_t inode, FileName *nameBuff) noexcept {
|
||||
ox::Error Directory<FileStore, InodeId_t>::write(PathIterator path, InodeId_t inode, FileName *nameBuff) noexcept {
|
||||
InodeId_t nextChild = 0;
|
||||
|
||||
// reuse nameBuff if it has already been allocated, as it is a rather large variable
|
||||
@ -260,7 +260,7 @@ Error Directory<FileStore, InodeId_t>::write(PathIterator path, InodeId_t inode,
|
||||
}
|
||||
|
||||
template<typename FileStore, typename InodeId_t>
|
||||
Error Directory<FileStore, InodeId_t>::remove(PathIterator path, FileName *nameBuff) noexcept {
|
||||
ox::Error Directory<FileStore, InodeId_t>::remove(PathIterator path, FileName *nameBuff) noexcept {
|
||||
// reuse nameBuff if it has already been allocated, as it is a rather large variable
|
||||
if (nameBuff == nullptr) {
|
||||
nameBuff = reinterpret_cast<FileName*>(ox_alloca(sizeof(FileName)));
|
||||
@ -291,7 +291,7 @@ Error Directory<FileStore, InodeId_t>::remove(PathIterator path, FileName *nameB
|
||||
|
||||
template<typename FileStore, typename InodeId_t>
|
||||
template<typename F>
|
||||
Error Directory<FileStore, InodeId_t>::ls(F cb) noexcept {
|
||||
ox::Error Directory<FileStore, InodeId_t>::ls(F cb) noexcept {
|
||||
oxTrace("ox::fs::Directory::ls");
|
||||
auto buff = m_fs.read(m_inodeId).template to<Buffer>();
|
||||
if (buff.valid()) {
|
||||
|
89
deps/ox/src/ox/fs/filesystem/filesystem.hpp
vendored
89
deps/ox/src/ox/fs/filesystem/filesystem.hpp
vendored
@ -20,32 +20,32 @@ class FileSystem {
|
||||
public:
|
||||
virtual ~FileSystem() = default;
|
||||
|
||||
virtual Error mkdir(const char *path, bool recursive = false) = 0;
|
||||
virtual ox::Error mkdir(const char *path, bool recursive = false) = 0;
|
||||
|
||||
/**
|
||||
* Moves an entry from one directory to another.
|
||||
* @param src the path to the file
|
||||
* @param dest the path of the destination directory
|
||||
*/
|
||||
virtual Error move(const char *src, const char *dest) = 0;
|
||||
virtual ox::Error move(const char *src, const char *dest) = 0;
|
||||
|
||||
virtual Error read(const char *path, void *buffer, std::size_t buffSize) = 0;
|
||||
virtual ox::Error read(const char *path, void *buffer, std::size_t buffSize) = 0;
|
||||
|
||||
virtual Error read(uint64_t inode, void *buffer, std::size_t size) = 0;
|
||||
virtual ox::Error read(uint64_t inode, void *buffer, std::size_t size) = 0;
|
||||
|
||||
virtual Error read(uint64_t inode, std::size_t readStart, std::size_t readSize, void *buffer, std::size_t *size) = 0;
|
||||
virtual ox::Error read(uint64_t inode, std::size_t readStart, std::size_t readSize, void *buffer, std::size_t *size) = 0;
|
||||
|
||||
virtual Error remove(const char *path, bool recursive = false) = 0;
|
||||
virtual ox::Error remove(const char *path, bool recursive = false) = 0;
|
||||
|
||||
virtual void resize(uint64_t size, void *buffer = nullptr) = 0;
|
||||
virtual ox::Error resize(uint64_t size, void *buffer = nullptr) = 0;
|
||||
|
||||
virtual Error write(const char *path, void *buffer, uint64_t size, uint8_t fileType = FileType_NormalFile) = 0;
|
||||
virtual ox::Error write(const char *path, void *buffer, uint64_t size, uint8_t fileType = FileType_NormalFile) = 0;
|
||||
|
||||
virtual Error write(uint64_t inode, void *buffer, uint64_t size, uint8_t fileType = FileType_NormalFile) = 0;
|
||||
virtual ox::Error write(uint64_t inode, void *buffer, uint64_t size, uint8_t fileType = FileType_NormalFile) = 0;
|
||||
|
||||
virtual ValErr<FileStat> stat(uint64_t inode) = 0;
|
||||
virtual ox::ValErr<FileStat> stat(uint64_t inode) = 0;
|
||||
|
||||
virtual ValErr<FileStat> stat(const char *path) = 0;
|
||||
virtual ox::ValErr<FileStat> stat(const char *path) = 0;
|
||||
|
||||
virtual uint64_t spaceNeeded(uint64_t size) = 0;
|
||||
|
||||
@ -55,7 +55,7 @@ class FileSystem {
|
||||
|
||||
virtual uint8_t *buff() = 0;
|
||||
|
||||
virtual Error walk(Error(*cb)(uint8_t, uint64_t, uint64_t)) = 0;
|
||||
virtual ox::Error walk(ox::Error(*cb)(uint8_t, uint64_t, uint64_t)) = 0;
|
||||
|
||||
virtual bool valid() const = 0;
|
||||
|
||||
@ -85,32 +85,32 @@ class FileSystemTemplate: public FileSystem {
|
||||
|
||||
~FileSystemTemplate();
|
||||
|
||||
static Error format(void *buff, uint64_t buffSize);
|
||||
[[nodiscard]] static ox::Error format(void *buff, uint64_t buffSize);
|
||||
|
||||
Error mkdir(const char *path, bool recursive = false) override;
|
||||
[[nodiscard]] ox::Error mkdir(const char *path, bool recursive = false) override;
|
||||
|
||||
Error move(const char *src, const char *dest) override;
|
||||
[[nodiscard]] ox::Error move(const char *src, const char *dest) override;
|
||||
|
||||
Error read(const char *path, void *buffer, std::size_t buffSize) override;
|
||||
[[nodiscard]] ox::Error read(const char *path, void *buffer, std::size_t buffSize) override;
|
||||
|
||||
Error read(uint64_t inode, void *buffer, std::size_t size) override;
|
||||
[[nodiscard]] ox::Error read(uint64_t inode, void *buffer, std::size_t size) override;
|
||||
|
||||
Error read(uint64_t inode, std::size_t readStart, std::size_t readSize, void *buffer, std::size_t *size) override;
|
||||
[[nodiscard]] ox::Error read(uint64_t inode, std::size_t readStart, std::size_t readSize, void *buffer, std::size_t *size) override;
|
||||
|
||||
template<typename F>
|
||||
Error ls(const char *dir, F cb);
|
||||
[[nodiscard]] ox::Error ls(const char *dir, F cb);
|
||||
|
||||
Error remove(const char *path, bool recursive = false) override;
|
||||
[[nodiscard]] ox::Error remove(const char *path, bool recursive = false) override;
|
||||
|
||||
void resize(uint64_t size, void *buffer = nullptr) override;
|
||||
[[nodiscard]] ox::Error resize(uint64_t size, void *buffer = nullptr) override;
|
||||
|
||||
Error write(const char *path, void *buffer, uint64_t size, uint8_t fileType = FileType_NormalFile) override;
|
||||
[[nodiscard]] ox::Error write(const char *path, void *buffer, uint64_t size, uint8_t fileType = FileType_NormalFile) override;
|
||||
|
||||
Error write(uint64_t inode, void *buffer, uint64_t size, uint8_t fileType = FileType_NormalFile) override;
|
||||
[[nodiscard]] ox::Error write(uint64_t inode, void *buffer, uint64_t size, uint8_t fileType = FileType_NormalFile) override;
|
||||
|
||||
ValErr<FileStat> stat(uint64_t inode) override;
|
||||
[[nodiscard]] ox::ValErr<FileStat> stat(uint64_t inode) override;
|
||||
|
||||
ValErr<FileStat> stat(const char *path) override;
|
||||
[[nodiscard]] ox::ValErr<FileStat> stat(const char *path) override;
|
||||
|
||||
uint64_t spaceNeeded(uint64_t size) override;
|
||||
|
||||
@ -120,19 +120,19 @@ class FileSystemTemplate: public FileSystem {
|
||||
|
||||
uint8_t *buff() override;
|
||||
|
||||
Error walk(Error(*cb)(uint8_t, uint64_t, uint64_t)) override;
|
||||
[[nodiscard]] ox::Error walk(ox::Error(*cb)(uint8_t, uint64_t, uint64_t)) override;
|
||||
|
||||
bool valid() const override;
|
||||
|
||||
private:
|
||||
ValErr<FileSystemData> fileSystemData() const noexcept;
|
||||
[[nodiscard]] ValErr<FileSystemData> fileSystemData() const noexcept;
|
||||
|
||||
/**
|
||||
* Finds the inode ID at the given path.
|
||||
*/
|
||||
ValErr<uint64_t> find(const char *path) const noexcept;
|
||||
[[nodiscard]] ValErr<uint64_t> find(const char *path) const noexcept;
|
||||
|
||||
ValErr<Directory> rootDir() const noexcept;
|
||||
[[nodiscard]] ValErr<Directory> rootDir() const noexcept;
|
||||
|
||||
};
|
||||
|
||||
@ -146,7 +146,7 @@ FileSystemTemplate<FileStore, Directory>::~FileSystemTemplate() {
|
||||
}
|
||||
|
||||
template<typename FileStore, typename Directory>
|
||||
Error FileSystemTemplate<FileStore, Directory>::format(void *buff, uint64_t buffSize) {
|
||||
ox::Error FileSystemTemplate<FileStore, Directory>::format(void *buff, uint64_t buffSize) {
|
||||
oxReturnError(FileStore::format(buff, buffSize));
|
||||
FileStore fs(buff, buffSize);
|
||||
|
||||
@ -167,7 +167,7 @@ Error FileSystemTemplate<FileStore, Directory>::format(void *buff, uint64_t buff
|
||||
}
|
||||
|
||||
template<typename FileStore, typename Directory>
|
||||
Error FileSystemTemplate<FileStore, Directory>::mkdir(const char *path, bool recursive) {
|
||||
ox::Error FileSystemTemplate<FileStore, Directory>::mkdir(const char *path, bool recursive) {
|
||||
oxTrace("ox::fs::FileSystemTemplate::mkdir") << "path:" << path << "recursive:" << recursive;
|
||||
auto rootDir = this->rootDir();
|
||||
oxReturnError(rootDir.error);
|
||||
@ -175,7 +175,7 @@ Error FileSystemTemplate<FileStore, Directory>::mkdir(const char *path, bool rec
|
||||
}
|
||||
|
||||
template<typename FileStore, typename Directory>
|
||||
Error FileSystemTemplate<FileStore, Directory>::move(const char *src, const char *dest) {
|
||||
ox::Error FileSystemTemplate<FileStore, Directory>::move(const char *src, const char *dest) {
|
||||
auto fd = fileSystemData();
|
||||
oxReturnError(fd.error);
|
||||
Directory rootDir(m_fs, fd.value.rootDirInode);
|
||||
@ -187,7 +187,7 @@ Error FileSystemTemplate<FileStore, Directory>::move(const char *src, const char
|
||||
}
|
||||
|
||||
template<typename FileStore, typename Directory>
|
||||
Error FileSystemTemplate<FileStore, Directory>::read(const char *path, void *buffer, std::size_t buffSize) {
|
||||
ox::Error FileSystemTemplate<FileStore, Directory>::read(const char *path, void *buffer, std::size_t buffSize) {
|
||||
auto fd = fileSystemData();
|
||||
oxReturnError(fd.error);
|
||||
Directory rootDir(m_fs, fd.value.rootDirInode);
|
||||
@ -197,29 +197,27 @@ Error FileSystemTemplate<FileStore, Directory>::read(const char *path, void *buf
|
||||
}
|
||||
|
||||
template<typename FileStore, typename Directory>
|
||||
Error FileSystemTemplate<FileStore, Directory>::read(uint64_t inode, void *buffer, std::size_t buffSize) {
|
||||
ox::Error FileSystemTemplate<FileStore, Directory>::read(uint64_t inode, void *buffer, std::size_t buffSize) {
|
||||
return m_fs.read(inode, buffer, buffSize);
|
||||
}
|
||||
|
||||
template<typename FileStore, typename Directory>
|
||||
Error FileSystemTemplate<FileStore, Directory>::read(uint64_t inode, std::size_t readStart, std::size_t readSize, void *buffer, std::size_t *size) {
|
||||
ox::Error FileSystemTemplate<FileStore, Directory>::read(uint64_t inode, std::size_t readStart, std::size_t readSize, void *buffer, std::size_t *size) {
|
||||
return m_fs.read(inode, readStart, readSize, reinterpret_cast<uint8_t*>(buffer), size);
|
||||
}
|
||||
|
||||
template<typename FileStore, typename Directory>
|
||||
template<typename F>
|
||||
Error FileSystemTemplate<FileStore, Directory>::ls(const char *path, F cb) {
|
||||
ox::Error FileSystemTemplate<FileStore, Directory>::ls(const char *path, F cb) {
|
||||
auto s = stat(path);
|
||||
oxReturnError(s.error);
|
||||
|
||||
Directory dir(m_fs, s.value.inode);
|
||||
dir.ls(cb);
|
||||
|
||||
return OxError(0);
|
||||
return dir.ls(cb);
|
||||
}
|
||||
|
||||
template<typename FileStore, typename Directory>
|
||||
Error FileSystemTemplate<FileStore, Directory>::remove(const char *path, bool recursive) {
|
||||
ox::Error FileSystemTemplate<FileStore, Directory>::remove(const char *path, bool recursive) {
|
||||
auto fd = fileSystemData();
|
||||
oxReturnError(fd.error);
|
||||
Directory rootDir(m_fs, fd.value.rootDirInode);
|
||||
@ -241,12 +239,13 @@ Error FileSystemTemplate<FileStore, Directory>::remove(const char *path, bool re
|
||||
}
|
||||
|
||||
template<typename FileStore, typename Directory>
|
||||
void FileSystemTemplate<FileStore, Directory>::resize(uint64_t size, void *buffer) {
|
||||
m_fs.resize(size, buffer);
|
||||
ox::Error FileSystemTemplate<FileStore, Directory>::resize(uint64_t size, void *buffer) {
|
||||
oxReturnError(m_fs.resize(size, buffer));
|
||||
return OxError(0);
|
||||
}
|
||||
|
||||
template<typename FileStore, typename Directory>
|
||||
Error FileSystemTemplate<FileStore, Directory>::write(const char *path, void *buffer, uint64_t size, uint8_t fileType) {
|
||||
ox::Error FileSystemTemplate<FileStore, Directory>::write(const char *path, void *buffer, uint64_t size, uint8_t fileType) {
|
||||
auto inode = find(path);
|
||||
if (inode.error) {
|
||||
inode.value = m_fs.generateInodeId();
|
||||
@ -259,7 +258,7 @@ Error FileSystemTemplate<FileStore, Directory>::write(const char *path, void *bu
|
||||
}
|
||||
|
||||
template<typename FileStore, typename Directory>
|
||||
Error FileSystemTemplate<FileStore, Directory>::write(uint64_t inode, void *buffer, uint64_t size, uint8_t fileType) {
|
||||
ox::Error FileSystemTemplate<FileStore, Directory>::write(uint64_t inode, void *buffer, uint64_t size, uint8_t fileType) {
|
||||
return m_fs.write(inode, buffer, size, fileType);
|
||||
}
|
||||
|
||||
@ -304,7 +303,7 @@ uint8_t *FileSystemTemplate<FileStore, Directory>::buff() {
|
||||
}
|
||||
|
||||
template<typename FileStore, typename Directory>
|
||||
Error FileSystemTemplate<FileStore, Directory>::walk(Error(*cb)(uint8_t, uint64_t, uint64_t)) {
|
||||
ox::Error FileSystemTemplate<FileStore, Directory>::walk(ox::Error(*cb)(uint8_t, uint64_t, uint64_t)) {
|
||||
return m_fs.walk(cb);
|
||||
}
|
||||
|
||||
|
@ -76,8 +76,9 @@ Error PassThroughFS::remove(const char *path, bool recursive) {
|
||||
}
|
||||
}
|
||||
|
||||
void PassThroughFS::resize(uint64_t, void*) {
|
||||
ox::Error PassThroughFS::resize(uint64_t, void*) {
|
||||
// unsupported
|
||||
return OxError(1);
|
||||
}
|
||||
|
||||
Error PassThroughFS::write(const char *path, void *buffer, uint64_t size, uint8_t) {
|
||||
|
28
deps/ox/src/ox/fs/filesystem/passthroughfs.hpp
vendored
28
deps/ox/src/ox/fs/filesystem/passthroughfs.hpp
vendored
@ -31,30 +31,30 @@ class PassThroughFS: public FileSystem {
|
||||
|
||||
[[nodiscard]] std::string basePath();
|
||||
|
||||
Error mkdir(const char *path, bool recursive = false) override;
|
||||
ox::Error mkdir(const char *path, bool recursive = false) override;
|
||||
|
||||
Error move(const char *src, const char *dest) override;
|
||||
ox::Error move(const char *src, const char *dest) override;
|
||||
|
||||
Error read(const char *path, void *buffer, std::size_t buffSize) override;
|
||||
ox::Error read(const char *path, void *buffer, std::size_t buffSize) override;
|
||||
|
||||
Error read(uint64_t inode, void *buffer, std::size_t size) override;
|
||||
ox::Error read(uint64_t inode, void *buffer, std::size_t size) override;
|
||||
|
||||
Error read(uint64_t inode, std::size_t readStart, std::size_t readSize, void *buffer, std::size_t *size) override;
|
||||
ox::Error read(uint64_t inode, std::size_t readStart, std::size_t readSize, void *buffer, std::size_t *size) override;
|
||||
|
||||
template<typename F>
|
||||
Error ls(const char *dir, F cb);
|
||||
ox::Error ls(const char *dir, F cb);
|
||||
|
||||
Error remove(const char *path, bool recursive = false) override;
|
||||
ox::Error remove(const char *path, bool recursive = false) override;
|
||||
|
||||
void resize(uint64_t size, void *buffer = nullptr) override;
|
||||
ox::Error resize(uint64_t size, void *buffer = nullptr) override;
|
||||
|
||||
Error write(const char *path, void *buffer, uint64_t size, uint8_t fileType = FileType_NormalFile) override;
|
||||
ox::Error write(const char *path, void *buffer, uint64_t size, uint8_t fileType = FileType_NormalFile) override;
|
||||
|
||||
Error write(uint64_t inode, void *buffer, uint64_t size, uint8_t fileType = FileType_NormalFile) override;
|
||||
ox::Error write(uint64_t inode, void *buffer, uint64_t size, uint8_t fileType = FileType_NormalFile) override;
|
||||
|
||||
ValErr<FileStat> stat(uint64_t inode) override;
|
||||
ox::ValErr<FileStat> stat(uint64_t inode) override;
|
||||
|
||||
ValErr<FileStat> stat(const char *path) override;
|
||||
ox::ValErr<FileStat> stat(const char *path) override;
|
||||
|
||||
uint64_t spaceNeeded(uint64_t size) override;
|
||||
|
||||
@ -64,7 +64,7 @@ class PassThroughFS: public FileSystem {
|
||||
|
||||
uint8_t *buff() override;
|
||||
|
||||
Error walk(Error(*cb)(uint8_t, uint64_t, uint64_t)) override;
|
||||
ox::Error walk(Error(*cb)(uint8_t, uint64_t, uint64_t)) override;
|
||||
|
||||
bool valid() const override;
|
||||
|
||||
@ -77,7 +77,7 @@ class PassThroughFS: public FileSystem {
|
||||
};
|
||||
|
||||
template<typename F>
|
||||
Error PassThroughFS::ls(const char *dir, F cb) {
|
||||
ox::Error PassThroughFS::ls(const char *dir, F cb) {
|
||||
for (auto &p : std::filesystem::directory_iterator(m_path / stripSlash(dir))) {
|
||||
if (auto err = cb(p.path().filename().c_str(), 0); err) {
|
||||
return err;
|
||||
|
2
deps/ox/src/ox/fs/test/tests.cpp
vendored
2
deps/ox/src/ox/fs/test/tests.cpp
vendored
@ -170,7 +170,7 @@ map<string, int(*)(string)> tests = {
|
||||
"Directory",
|
||||
[](string) {
|
||||
std::vector<uint8_t> fsBuff(5000);
|
||||
ox::FileStore32::format(fsBuff.data(), fsBuff.size());
|
||||
oxAssert(ox::FileStore32::format(fsBuff.data(), fsBuff.size()), "FS format failed");
|
||||
ox::FileStore32 fileStore(fsBuff.data(), fsBuff.size());
|
||||
auto dir = ox_malloca(1000, ox::Directory32, fileStore, 100);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user