diff --git a/deps/ox/src/ox/fs/filesystem/filesystem.cpp b/deps/ox/src/ox/fs/filesystem/filesystem.cpp index b566db63..134b7c18 100644 --- a/deps/ox/src/ox/fs/filesystem/filesystem.cpp +++ b/deps/ox/src/ox/fs/filesystem/filesystem.cpp @@ -12,7 +12,7 @@ namespace ox { -Result FileSystem::directAccess(FileAddress addr) noexcept { +Result FileSystem::directAccess(const FileAddress &addr) noexcept { switch (addr.type()) { case FileAddressType::Inode: return directAccess(addr.getInode().value); @@ -24,7 +24,7 @@ Result 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> FileSystem::read(FileAddress addr) noexcept { +Result> FileSystem::read(const FileAddress &addr) noexcept { oxRequire(s, stat(addr)); ox::Vector 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> 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 FileSystem::stat(FileAddress addr) noexcept { +Result FileSystem::stat(const FileAddress &addr) noexcept { switch (addr.type()) { case FileAddressType::Inode: return stat(addr.getInode().value); diff --git a/deps/ox/src/ox/fs/filesystem/filesystem.hpp b/deps/ox/src/ox/fs/filesystem/filesystem.hpp index 8a443339..27d75387 100644 --- a/deps/ox/src/ox/fs/filesystem/filesystem.hpp +++ b/deps/ox/src/ox/fs/filesystem/filesystem.hpp @@ -40,13 +40,13 @@ class FileSystem { virtual Result 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> read(FileAddress addr) noexcept; + Result> 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 directAccess(FileAddress addr) noexcept; + Result directAccess(const FileAddress &addr) noexcept; Result> 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 stat(uint64_t inode) noexcept = 0; virtual Result stat(const char *path) noexcept = 0; - Result stat(FileAddress addr) noexcept; + Result stat(const FileAddress &addr) noexcept; [[nodiscard]] virtual uint64_t spaceNeeded(uint64_t size) noexcept = 0;