mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-06 19:41:51 +00:00
update io::Device::read
This commit is contained in:
parent
dceb5f6ee4
commit
3e67d887f4
5 changed files with 72 additions and 29 deletions
|
|
@ -35,13 +35,13 @@ void StdfsDevice::write(std::string_view path, const void* data, size_t size) {
|
|||
output.write((const char*)data, size);
|
||||
}
|
||||
|
||||
void StdfsDevice::read(std::string_view path, void* data, size_t size) {
|
||||
std::unique_ptr<std::istream> StdfsDevice::read(std::string_view path) {
|
||||
auto resolved = resolve(path);
|
||||
std::ifstream input(resolved, std::ios::binary);
|
||||
if (!input.is_open()) {
|
||||
auto input = std::make_unique<std::ifstream>(resolved, std::ios::binary);
|
||||
if (!*input) {
|
||||
throw std::runtime_error("could not to open file " + resolved.u8string());
|
||||
}
|
||||
input.read((char*)data, size);
|
||||
return input;
|
||||
}
|
||||
|
||||
size_t StdfsDevice::size(std::string_view path) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue