mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-19 15:52:53 +00:00
ZoneCodeGenerator: Add Dumping step for testing purposes
This commit is contained in:
parent
a1670305c7
commit
91d76382f3
38
src/ZoneLoading/Loading/Steps/StepDumpData.cpp
Normal file
38
src/ZoneLoading/Loading/Steps/StepDumpData.cpp
Normal 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();
|
||||||
|
}
|
13
src/ZoneLoading/Loading/Steps/StepDumpData.h
Normal file
13
src/ZoneLoading/Loading/Steps/StepDumpData.h
Normal 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;
|
||||||
|
};
|
Loading…
x
Reference in New Issue
Block a user