ZoneCodeGenerator: Add Dumping step for testing purposes

This commit is contained in:
Jan 2019-10-21 17:01:48 +02:00
parent a1670305c7
commit 91d76382f3
2 changed files with 51 additions and 0 deletions

View File

@ -0,0 +1,38 @@
#include "StepDumpData.h"
StepDumpData::StepDumpData(const unsigned int dumpCount)
{
m_dump_count = dumpCount;
}
void StepDumpData::PerformStep(ZoneLoader* zoneLoader, ILoadingStream* stream)
{
uint8_t tempBuffer[128];
unsigned int dumpedBytes = 0;
FileAPI::File tempFile = FileAPI::Open("dump.dat", FileAPI::Mode::MODE_WRITE);
while (dumpedBytes < m_dump_count)
{
unsigned int toDump;
if (m_dump_count - dumpedBytes < sizeof(tempBuffer))
{
toDump = m_dump_count - dumpedBytes;
}
else
{
toDump = sizeof(tempBuffer);
}
const size_t loadedSize = stream->Load(tempBuffer, toDump);
dumpedBytes += loadedSize;
if (loadedSize == 0)
break;
tempFile.Write(tempBuffer, 1, loadedSize);
}
tempFile.Close();
}

View File

@ -0,0 +1,13 @@
#pragma once
#include "Loading/ILoadingStep.h"
class StepDumpData final : public ILoadingStep
{
unsigned int m_dump_count;
public:
explicit StepDumpData(unsigned int dumpCount);
void PerformStep(ZoneLoader* zoneLoader, ILoadingStream* stream) override;
};