Fixup UserModule::LoadFromFile to use new vfs API
This commit is contained in:
parent
f4154810b6
commit
3e6c70defa
|
@ -53,23 +53,25 @@ X_STATUS UserModule::LoadFromFile(std::string path) {
|
||||||
std::vector<uint8_t> buffer(fs_entry->size());
|
std::vector<uint8_t> buffer(fs_entry->size());
|
||||||
|
|
||||||
// Open file for reading.
|
// Open file for reading.
|
||||||
object_ref<XFile> file;
|
vfs::File* file = nullptr;
|
||||||
result =
|
result = fs_entry->Open(vfs::FileAccess::kGenericRead, &file);
|
||||||
fs_entry->Open(kernel_state(), vfs::FileAccess::kGenericRead, &file);
|
if (XFAILED(result)) {
|
||||||
if (result) {
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read entire file into memory.
|
// Read entire file into memory.
|
||||||
// Ugh.
|
// Ugh.
|
||||||
size_t bytes_read = 0;
|
size_t bytes_read = 0;
|
||||||
result = file->Read(buffer.data(), buffer.size(), 0, &bytes_read);
|
result = file->ReadSync(buffer.data(), buffer.size(), 0, &bytes_read);
|
||||||
if (result) {
|
if (XFAILED(result)) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load the module.
|
// Load the module.
|
||||||
result = LoadFromMemory(buffer.data(), bytes_read);
|
result = LoadFromMemory(buffer.data(), bytes_read);
|
||||||
|
|
||||||
|
// Close the file.
|
||||||
|
file->Destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
Loading…
Reference in New Issue