mirror of
https://github.com/OpenMW/openmw.git
synced 2025-04-10 18:36:46 +00:00
Use the right size
This commit is contained in:
parent
16628a766f
commit
3b1d6a7e62
1 changed files with 7 additions and 9 deletions
|
@ -202,23 +202,21 @@ namespace Bsa
|
||||||
|
|
||||||
Files::IStreamPtr BA2GNRLFile::getFile(const FileRecord& fileRecord)
|
Files::IStreamPtr BA2GNRLFile::getFile(const FileRecord& fileRecord)
|
||||||
{
|
{
|
||||||
Files::IStreamPtr streamPtr
|
const uint32_t inputSize = fileRecord.packedSize ? fileRecord.packedSize : fileRecord.size;
|
||||||
= Files::openConstrainedFileStream(mFilepath, fileRecord.offset, fileRecord.packedSize);
|
Files::IStreamPtr streamPtr = Files::openConstrainedFileStream(mFilepath, fileRecord.offset, inputSize);
|
||||||
std::istream* fileStream = streamPtr.get();
|
auto memoryStreamPtr = std::make_unique<MemoryInputStream>(fileRecord.size);
|
||||||
uint32_t uncompressedSize = fileRecord.size;
|
if (fileRecord.packedSize)
|
||||||
auto memoryStreamPtr = std::make_unique<MemoryInputStream>(uncompressedSize);
|
|
||||||
if (fileRecord.packedSize != 0)
|
|
||||||
{
|
{
|
||||||
boost::iostreams::filtering_streambuf<boost::iostreams::input> inputStreamBuf;
|
boost::iostreams::filtering_streambuf<boost::iostreams::input> inputStreamBuf;
|
||||||
inputStreamBuf.push(boost::iostreams::zlib_decompressor());
|
inputStreamBuf.push(boost::iostreams::zlib_decompressor());
|
||||||
inputStreamBuf.push(*fileStream);
|
inputStreamBuf.push(*streamPtr);
|
||||||
|
|
||||||
boost::iostreams::basic_array_sink<char> sr(memoryStreamPtr->getRawData(), uncompressedSize);
|
boost::iostreams::basic_array_sink<char> sr(memoryStreamPtr->getRawData(), fileRecord.size);
|
||||||
boost::iostreams::copy(inputStreamBuf, sr);
|
boost::iostreams::copy(inputStreamBuf, sr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fileStream->read(memoryStreamPtr->getRawData(), fileRecord.size);
|
streamPtr->read(memoryStreamPtr->getRawData(), fileRecord.size);
|
||||||
}
|
}
|
||||||
return std::make_unique<Files::StreamWithBuffer<MemoryInputStream>>(std::move(memoryStreamPtr));
|
return std::make_unique<Files::StreamWithBuffer<MemoryInputStream>>(std::move(memoryStreamPtr));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue