[ox/fs] Make directAccess return const char*

This commit is contained in:
Gary Talent 2021-05-03 22:06:24 -04:00
parent d49576451c
commit 25504d87af
4 changed files with 13 additions and 13 deletions

View File

@ -13,7 +13,7 @@
namespace ox {
Result<const uint8_t*> FileSystem::directAccess(const FileAddress &addr) noexcept {
Result<const char*> FileSystem::directAccess(const FileAddress &addr) noexcept {
switch (addr.type()) {
case FileAddressType::Inode:
return directAccess(addr.getInode().value);

View File

@ -34,13 +34,13 @@ class FileSystem {
virtual Error read(const char *path, void *buffer, std::size_t buffSize) noexcept = 0;
virtual Result<const uint8_t*> directAccess(const char *path) noexcept = 0;
virtual Result<const char*> directAccess(const char *path) noexcept = 0;
virtual Error read(uint64_t inode, void *buffer, std::size_t size) noexcept = 0;
virtual Error read(uint64_t inode, std::size_t readStart, std::size_t readSize, void *buffer, std::size_t *size) noexcept = 0;
virtual Result<const uint8_t*> directAccess(uint64_t inode) noexcept = 0;
virtual Result<const char*> directAccess(uint64_t inode) noexcept = 0;
Error read(const FileAddress &addr, void *buffer, std::size_t size) noexcept;
@ -48,7 +48,7 @@ class FileSystem {
Error read(const FileAddress &addr, std::size_t readStart, std::size_t readSize, void *buffer, std::size_t *size) noexcept;
Result<const uint8_t*> directAccess(const FileAddress &addr) noexcept;
Result<const char*> directAccess(const FileAddress &addr) noexcept;
Result<Vector<String>> ls(const ox::String &dir) noexcept;
@ -124,13 +124,13 @@ class FileSystemTemplate: public FileSystem {
Error read(const char *path, void *buffer, std::size_t buffSize) noexcept override;
Result<const uint8_t*> directAccess(const char*) noexcept override;
Result<const char*> directAccess(const char*) 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 uint8_t*> directAccess(uint64_t) noexcept override;
Result<const char*> directAccess(uint64_t) noexcept override;
Result<Vector<String>> ls(const char *dir) noexcept override;
@ -249,7 +249,7 @@ Error FileSystemTemplate<FileStore, Directory>::read(const char *path, void *buf
}
template<typename FileStore, typename Directory>
Result<const uint8_t*> FileSystemTemplate<FileStore, Directory>::directAccess(const char *path) noexcept {
Result<const char*> FileSystemTemplate<FileStore, Directory>::directAccess(const char *path) noexcept {
auto fd = fileSystemData();
oxReturnError(fd.error);
Directory rootDir(m_fs, fd.value.rootDirInode);
@ -269,12 +269,12 @@ Error FileSystemTemplate<FileStore, Directory>::read(uint64_t inode, std::size_t
}
template<typename FileStore, typename Directory>
Result<const uint8_t*> FileSystemTemplate<FileStore, Directory>::directAccess(uint64_t inode) noexcept {
Result<const char*> FileSystemTemplate<FileStore, Directory>::directAccess(uint64_t inode) noexcept {
auto data = m_fs.read(inode);
if (!data.valid()) {
return OxError(1);
}
return data.get();
return bit_cast<char*>(data.get());
}
template<typename FileStore, typename Directory>

View File

@ -76,7 +76,7 @@ Error PassThroughFS::read(const char *path, void *buffer, std::size_t buffSize)
return OxError(0);
}
Result<const uint8_t*> PassThroughFS::directAccess(const char*) noexcept {
Result<const char*> PassThroughFS::directAccess(const char*) noexcept {
return OxError(1, "PassThroughFS::directAccess not supported");
}
@ -90,7 +90,7 @@ Error PassThroughFS::read(uint64_t, std::size_t, std::size_t, void*, std::size_t
return OxError(1);
}
Result<const uint8_t*> PassThroughFS::directAccess(uint64_t) noexcept {
Result<const char*> PassThroughFS::directAccess(uint64_t) noexcept {
return OxError(1, "PassThroughFS::directAccess not supported");
}

View File

@ -43,13 +43,13 @@ class PassThroughFS: public FileSystem {
Error read(const char *path, void *buffer, std::size_t buffSize) noexcept override;
Result<const uint8_t*> directAccess(const char*) noexcept override;
Result<const char*> directAccess(const char*) 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 uint8_t*> directAccess(uint64_t) noexcept override;
Result<const char*> directAccess(uint64_t) noexcept override;
Result<Vector<String>> ls(const char *dir) noexcept override;