[ox/fs] Add Result<Vector<char>> FileSystem::read
This commit is contained in:
parent
863437fb10
commit
4540b410dc
9
deps/ox/src/ox/fs/filesystem/filesystem.cpp
vendored
9
deps/ox/src/ox/fs/filesystem/filesystem.cpp
vendored
@ -6,6 +6,8 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#include <ox/std/utility.hpp>
|
||||
|
||||
#include "filesystem.hpp"
|
||||
|
||||
namespace ox {
|
||||
@ -34,6 +36,13 @@ Error FileSystem::read(FileAddress addr, void *buffer, std::size_t size) noexcep
|
||||
}
|
||||
}
|
||||
|
||||
Result<Vector<char>> FileSystem::read(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 {
|
||||
switch (addr.type()) {
|
||||
case FileAddressType::Inode:
|
||||
|
2
deps/ox/src/ox/fs/filesystem/filesystem.hpp
vendored
2
deps/ox/src/ox/fs/filesystem/filesystem.hpp
vendored
@ -42,6 +42,8 @@ class FileSystem {
|
||||
|
||||
Error read(FileAddress addr, void *buffer, std::size_t size) noexcept;
|
||||
|
||||
Result<Vector<char>> read(FileAddress addr) noexcept;
|
||||
|
||||
Error read(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;
|
||||
|
Loading…
Reference in New Issue
Block a user