[ox/fs] Make FileAddress args into const refs
This commit is contained in:
parent
4f2c0b2e30
commit
937bf3ad91
14
deps/ox/src/ox/fs/filesystem/filesystem.cpp
vendored
14
deps/ox/src/ox/fs/filesystem/filesystem.cpp
vendored
@ -12,7 +12,7 @@
|
||||
|
||||
namespace ox {
|
||||
|
||||
Result<const uint8_t*> FileSystem::directAccess(FileAddress addr) noexcept {
|
||||
Result<const uint8_t*> FileSystem::directAccess(const FileAddress &addr) noexcept {
|
||||
switch (addr.type()) {
|
||||
case FileAddressType::Inode:
|
||||
return directAccess(addr.getInode().value);
|
||||
@ -24,7 +24,7 @@ Result<const uint8_t*> FileSystem::directAccess(FileAddress addr) noexcept {
|
||||
}
|
||||
}
|
||||
|
||||
Error FileSystem::read(FileAddress addr, void *buffer, std::size_t size) noexcept {
|
||||
Error FileSystem::read(const FileAddress &addr, void *buffer, std::size_t size) noexcept {
|
||||
switch (addr.type()) {
|
||||
case FileAddressType::Inode:
|
||||
return read(addr.getInode().value, buffer, size);
|
||||
@ -36,14 +36,14 @@ Error FileSystem::read(FileAddress addr, void *buffer, std::size_t size) noexcep
|
||||
}
|
||||
}
|
||||
|
||||
Result<Vector<char>> FileSystem::read(FileAddress addr) noexcept {
|
||||
Result<Vector<char>> FileSystem::read(const FileAddress &addr) noexcept {
|
||||
oxRequire(s, stat(addr));
|
||||
ox::Vector<char> buff(s.size);
|
||||
oxReturnError(read(addr, buff.data(), buff.size()));
|
||||
return ox::move(buff);
|
||||
}
|
||||
|
||||
Error FileSystem::read(FileAddress addr, std::size_t readStart, std::size_t readSize, void *buffer, std::size_t *size) noexcept {
|
||||
Error FileSystem::read(const FileAddress &addr, std::size_t readStart, std::size_t readSize, void *buffer, std::size_t *size) noexcept {
|
||||
switch (addr.type()) {
|
||||
case FileAddressType::Inode:
|
||||
return read(addr.getInode().value, readStart, readSize, buffer, size);
|
||||
@ -59,7 +59,7 @@ Result<Vector<String>> FileSystem::ls(const ox::String &dir) noexcept {
|
||||
return ls(dir.c_str());
|
||||
}
|
||||
|
||||
Error FileSystem::remove(FileAddress addr, bool recursive) noexcept {
|
||||
Error FileSystem::remove(const FileAddress &addr, bool recursive) noexcept {
|
||||
switch (addr.type()) {
|
||||
case FileAddressType::Inode:
|
||||
return remove(addr.getInode().value, recursive);
|
||||
@ -71,7 +71,7 @@ Error FileSystem::remove(FileAddress addr, bool recursive) noexcept {
|
||||
}
|
||||
}
|
||||
|
||||
Error FileSystem::write(FileAddress addr, void *buffer, uint64_t size, uint8_t fileType) noexcept {
|
||||
Error FileSystem::write(const FileAddress &addr, void *buffer, uint64_t size, uint8_t fileType) noexcept {
|
||||
switch (addr.type()) {
|
||||
case FileAddressType::Inode:
|
||||
return write(addr.getInode().value, buffer, size, fileType);
|
||||
@ -83,7 +83,7 @@ Error FileSystem::write(FileAddress addr, void *buffer, uint64_t size, uint8_t f
|
||||
}
|
||||
}
|
||||
|
||||
Result<FileStat> FileSystem::stat(FileAddress addr) noexcept {
|
||||
Result<FileStat> FileSystem::stat(const FileAddress &addr) noexcept {
|
||||
switch (addr.type()) {
|
||||
case FileAddressType::Inode:
|
||||
return stat(addr.getInode().value);
|
||||
|
14
deps/ox/src/ox/fs/filesystem/filesystem.hpp
vendored
14
deps/ox/src/ox/fs/filesystem/filesystem.hpp
vendored
@ -40,13 +40,13 @@ class FileSystem {
|
||||
|
||||
virtual Result<const uint8_t*> directAccess(uint64_t inode) noexcept = 0;
|
||||
|
||||
Error read(FileAddress addr, void *buffer, std::size_t size) noexcept;
|
||||
Error read(const FileAddress &addr, void *buffer, std::size_t size) noexcept;
|
||||
|
||||
Result<Vector<char>> read(FileAddress addr) noexcept;
|
||||
Result<Vector<char>> read(const FileAddress &addr) noexcept;
|
||||
|
||||
Error read(FileAddress addr, std::size_t readStart, std::size_t readSize, void *buffer, std::size_t *size) noexcept;
|
||||
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(FileAddress addr) noexcept;
|
||||
Result<const uint8_t*> directAccess(const FileAddress &addr) noexcept;
|
||||
|
||||
Result<Vector<String>> ls(const ox::String &dir) noexcept;
|
||||
|
||||
@ -54,7 +54,7 @@ class FileSystem {
|
||||
|
||||
virtual Error remove(const char *path, bool recursive = false) noexcept = 0;
|
||||
|
||||
Error remove(FileAddress addr, bool recursive = false) noexcept;
|
||||
Error remove(const FileAddress &addr, bool recursive = false) noexcept;
|
||||
|
||||
virtual Error resize(uint64_t size, void *buffer = nullptr) noexcept = 0;
|
||||
|
||||
@ -62,13 +62,13 @@ class FileSystem {
|
||||
|
||||
virtual Error write(uint64_t inode, void *buffer, uint64_t size, uint8_t fileType = FileType_NormalFile) noexcept = 0;
|
||||
|
||||
Error write(FileAddress addr, void *buffer, uint64_t size, uint8_t fileType = FileType_NormalFile) noexcept;
|
||||
Error write(const FileAddress &addr, void *buffer, uint64_t size, uint8_t fileType = FileType_NormalFile) noexcept;
|
||||
|
||||
virtual Result<FileStat> stat(uint64_t inode) noexcept = 0;
|
||||
|
||||
virtual Result<FileStat> stat(const char *path) noexcept = 0;
|
||||
|
||||
Result<FileStat> stat(FileAddress addr) noexcept;
|
||||
Result<FileStat> stat(const FileAddress &addr) noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
virtual uint64_t spaceNeeded(uint64_t size) noexcept = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user