FS: Stream RomFS from file instead of loading all of it to memory

This commit is contained in:
condut
2015-07-10 00:55:23 +03:00
committed by Yuri Kunde Schlesner
parent ecdfd0643a
commit c385b7767d
9 changed files with 48 additions and 33 deletions

View File

@ -37,17 +37,14 @@ ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_SaveDataCheck::Open(co
auto vec = path.AsBinary();
const u32* data = reinterpret_cast<u32*>(vec.data());
std::string file_path = GetSaveDataCheckPath(mount_point, data[1], data[0]);
FileUtil::IOFile file(file_path, "rb");
auto file = std::make_shared<FileUtil::IOFile>(file_path, "rb");
if (!file.IsOpen()) {
if (!file->IsOpen()) {
return ResultCode(-1); // TODO(Subv): Find the right error code
}
auto size = file.GetSize();
auto raw_data = std::make_shared<std::vector<u8>>(size);
file.ReadBytes(raw_data->data(), size);
file.Close();
auto size = file->GetSize();
auto archive = Common::make_unique<IVFCArchive>(std::move(raw_data));
auto archive = Common::make_unique<IVFCArchive>(file, 0, size);
return MakeResult<std::unique_ptr<ArchiveBackend>>(std::move(archive));
}