mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-25 13:31:37 +00:00
simplification of MemoryArrayReader interface.
This commit is contained in:
parent
9bcbdfa09c
commit
235d36fe69
3 changed files with 3 additions and 33 deletions
|
@ -236,7 +236,6 @@ public:
|
||||||
bool OpenMemoryArray(const void *mem, Size length); // read from a copy of the buffer.
|
bool OpenMemoryArray(const void *mem, Size length); // read from a copy of the buffer.
|
||||||
bool OpenMemoryArray(std::vector<uint8_t>& data); // take the given array
|
bool OpenMemoryArray(std::vector<uint8_t>& data); // take the given array
|
||||||
bool OpenMemoryArray(FileData& data); // take the given array
|
bool OpenMemoryArray(FileData& data); // take the given array
|
||||||
bool OpenMemoryArray(std::function<bool(std::vector<uint8_t>&)> getter); // read contents to a buffer and return a reader to it
|
|
||||||
|
|
||||||
Size Tell() const
|
Size Tell() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -399,13 +399,6 @@ bool FileReader::OpenMemoryArray(const void *mem, FileReader::Size length)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FileReader::OpenMemoryArray(std::vector<uint8_t>& data)
|
|
||||||
{
|
|
||||||
Close();
|
|
||||||
if (data.size() > 0) mReader = new MemoryArrayReader<std::vector<uint8_t>>(data);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FileReader::OpenMemoryArray(FileData& data)
|
bool FileReader::OpenMemoryArray(FileData& data)
|
||||||
{
|
{
|
||||||
Close();
|
Close();
|
||||||
|
@ -413,23 +406,6 @@ bool FileReader::OpenMemoryArray(FileData& data)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FileReader::OpenMemoryArray(std::function<bool(std::vector<uint8_t>&)> getter)
|
|
||||||
{
|
|
||||||
auto reader = new MemoryArrayReader<std::vector<uint8_t>>(nullptr, 0);
|
|
||||||
if (getter(reader->GetArray()))
|
|
||||||
{
|
|
||||||
Close();
|
|
||||||
reader->UpdateBuffer();
|
|
||||||
mReader = reader;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// This will keep the old buffer, if one existed
|
|
||||||
delete reader;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
|
@ -317,14 +317,9 @@ unsigned FSavegameManagerBase::ExtractSaveData(int index)
|
||||||
if (pic >= 0)
|
if (pic >= 0)
|
||||||
{
|
{
|
||||||
FileReader picreader;
|
FileReader picreader;
|
||||||
|
// we must create a memory reader copy of the PNG if we want to close the savegame file here.
|
||||||
picreader.OpenMemoryArray([=](std::vector<uint8_t>& array)
|
auto rd = resf->Read(pic);
|
||||||
{
|
picreader.OpenMemoryArray(rd);
|
||||||
auto rd = resf->GetEntryReader(pic, false);
|
|
||||||
array.resize(resf->Length(pic));
|
|
||||||
rd.Read(array.data(), array.size());
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
PNGHandle *png = M_VerifyPNG(picreader);
|
PNGHandle *png = M_VerifyPNG(picreader);
|
||||||
if (png != nullptr)
|
if (png != nullptr)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue