[ox/fs] Make directAccess functions const

This commit is contained in:
Gary Talent 2023-06-03 22:04:02 -05:00
parent 5dd3b678ae
commit 8c7f6ffafc
2 changed files with 10 additions and 10 deletions

View File

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

View File

@ -126,20 +126,20 @@ class FileSystem {
class MemFS: public FileSystem {
public:
Result<const char*> directAccess(const FileAddress &addr) noexcept;
Result<const char*> directAccess(const FileAddress &addr) const noexcept;
inline Result<const char*> directAccess(CRStringView path) noexcept {
inline Result<const char*> directAccess(CRStringView path) const noexcept {
return directAccessPath(path);
}
inline Result<const char*> directAccess(uint64_t inode) noexcept {
inline Result<const char*> directAccess(uint64_t inode) const noexcept {
return directAccessInode(inode);
}
protected:
virtual Result<const char*> directAccessPath(CRStringView path) noexcept = 0;
virtual Result<const char*> directAccessPath(CRStringView path) const noexcept = 0;
virtual Result<const char*> directAccessInode(uint64_t inode) noexcept = 0;
virtual Result<const char*> directAccessInode(uint64_t inode) const noexcept = 0;
};
/**
@ -177,13 +177,13 @@ class FileSystemTemplate: public MemFS {
Error readFilePath(CRStringView path, void *buffer, std::size_t buffSize) noexcept override;
Result<const char*> directAccessPath(CRStringView) noexcept override;
Result<const char*> directAccessPath(CRStringView) const 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;
Result<const char*> directAccessInode(uint64_t) noexcept override;
Result<const char*> directAccessInode(uint64_t) const noexcept override;
Result<Vector<String>> ls(CRStringView dir) const noexcept override;
@ -302,7 +302,7 @@ Error FileSystemTemplate<FileStore, Directory>::readFilePath(CRStringView path,
}
template<typename FileStore, typename Directory>
Result<const char*> FileSystemTemplate<FileStore, Directory>::directAccessPath(CRStringView path) noexcept {
Result<const char*> FileSystemTemplate<FileStore, Directory>::directAccessPath(CRStringView path) const noexcept {
oxRequire(fd, fileSystemData());
Directory rootDir(m_fs, fd.rootDirInode);
oxRequire(inode, rootDir.find(path));
@ -324,7 +324,7 @@ Error FileSystemTemplate<FileStore, Directory>::readFileInodeRange(uint64_t inod
}
template<typename FileStore, typename Directory>
Result<const char*> FileSystemTemplate<FileStore, Directory>::directAccessInode(uint64_t inode) noexcept {
Result<const char*> FileSystemTemplate<FileStore, Directory>::directAccessInode(uint64_t inode) const noexcept {
auto data = m_fs.read(inode);
if (!data.valid()) {
return OxError(1, "Data not valid");