mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-20 07:45:26 +00:00
RE COutput/InputStream and friends and migrate over
This branch is probably still horribly broken, but it's a good first step to migrating away from having hecl embedded in the runtime
This commit is contained in:
@@ -44,7 +44,8 @@ std::unique_ptr<CInputStream> CResLoader::LoadNewResourcePartSync(const SObjectT
|
||||
|
||||
CPakFile* const file = FindResourceForLoad(tag);
|
||||
file->SyncSeekRead(buf, length, ESeekOrigin::Begin, x50_cachedResInfo->GetOffset() + offset);
|
||||
return std::make_unique<athena::io::MemoryReader>(buf, length, !extBuf);
|
||||
return std::make_unique<CMemoryInStream>(
|
||||
buf, length, extBuf == nullptr ? CMemoryInStream::EOwnerShip::Owned : CMemoryInStream::EOwnerShip::NotOwned);
|
||||
}
|
||||
|
||||
void CResLoader::LoadMemResourceSync(const SObjectTag& tag, std::unique_ptr<u8[]>& bufOut, int* sizeOut) {
|
||||
@@ -57,9 +58,10 @@ void CResLoader::LoadMemResourceSync(const SObjectTag& tag, std::unique_ptr<u8[]
|
||||
|
||||
std::unique_ptr<CInputStream> CResLoader::LoadResourceFromMemorySync(const SObjectTag& tag, const void* buf) {
|
||||
FindResourceForLoad(tag);
|
||||
std::unique_ptr<CInputStream> newStrm = std::make_unique<athena::io::MemoryReader>(buf, x50_cachedResInfo->GetSize());
|
||||
std::unique_ptr<CInputStream> newStrm =
|
||||
std::make_unique<CMemoryInStream>(buf, x50_cachedResInfo->GetSize(), CMemoryInStream::EOwnerShip::NotOwned);
|
||||
if (x50_cachedResInfo->IsCompressed()) {
|
||||
newStrm->readUint32Big();
|
||||
newStrm->ReadLong();
|
||||
newStrm = std::make_unique<CZipInputStream>(std::move(newStrm));
|
||||
}
|
||||
return newStrm;
|
||||
@@ -77,9 +79,10 @@ std::unique_ptr<CInputStream> CResLoader::LoadNewResourceSync(const SObjectTag&
|
||||
file->SyncSeekRead(buf, resSz, ESeekOrigin::Begin, x50_cachedResInfo->GetOffset());
|
||||
|
||||
const bool takeOwnership = extBuf == nullptr;
|
||||
std::unique_ptr<CInputStream> newStrm = std::make_unique<athena::io::MemoryReader>(buf, resSz, takeOwnership);
|
||||
std::unique_ptr<CInputStream> newStrm = std::make_unique<CMemoryInStream>(
|
||||
buf, resSz, takeOwnership ? CMemoryInStream::EOwnerShip::Owned : CMemoryInStream::EOwnerShip::NotOwned);
|
||||
if (x50_cachedResInfo->IsCompressed()) {
|
||||
newStrm->readUint32Big();
|
||||
newStrm->ReadLong();
|
||||
newStrm = std::make_unique<CZipInputStream>(std::move(newStrm));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user