1
0
mirror of synced 2024-11-28 09:30:51 +01:00

impr: Allow non-continuous provider values to be saved

This commit is contained in:
WerWolv 2023-03-17 08:38:38 +01:00
parent 4ee53701e6
commit 5442c32a3f

View File

@ -41,14 +41,22 @@ namespace hex::prv {
if (file.isValid()) {
std::vector<u8> buffer(std::min<size_t>(0xFF'FFFF, this->getActualSize()), 0x00);
size_t bufferSize = buffer.size();
size_t bufferSize = 0;
for (u64 offset = 0; offset < this->getActualSize(); offset += bufferSize) {
if (bufferSize > this->getActualSize() - offset)
bufferSize = this->getActualSize() - offset;
bufferSize = buffer.size();
auto [region, valid] = this->getRegionValidity(offset + this->getBaseAddress());
if (!valid)
offset = region.getEndAddress() + 1;
auto [newRegion, newValid] = this->getRegionValidity(offset + this->getBaseAddress());
bufferSize = std::min(bufferSize, (newRegion.getEndAddress() - offset) + 1);
bufferSize = std::min(bufferSize, this->getActualSize() - offset);
this->read(offset + this->getBaseAddress(), buffer.data(), bufferSize, true);
file.write(buffer.data(), bufferSize);
}
}
}