MCPcopy Create free account
hub / github.com/TombEngine/TombEngine / ReadChunks

Method ReadChunks

TombEngine/Specific/IO/ChunkReader.cpp:48–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46}
47
48bool ChunkReader::ReadChunks(bool(*func)(ChunkId* parentChunkId, int maxSize, int arg), int arg)
49{
50 do
51 {
52 std::unique_ptr<ChunkId> chunkId = ChunkId::FromStream(m_stream);
53 if (chunkId->EqualsTo(m_emptyChunk)) // End reached
54 break;
55
56 // Read up to a 64 bit number for the chunk size
57 __int64 chunkSize = LEB128::ReadLong(m_stream);
58
59 // Try loading chunk content
60 bool chunkRecognized = false;
61 int startPos = m_stream->GetCurrentPosition();
62
63 chunkRecognized = func(chunkId.get(), chunkSize, arg);
64 int readDataCount = m_stream->GetCurrentPosition() - startPos;
65
66 // Adjust _stream position if necessary
67 if (readDataCount != chunkSize)
68 m_stream->Seek(chunkSize - readDataCount, SeekOrigin::CURRENT);
69 }
70 while (true);
71
72 return true;
73}
74
75bool ChunkReader::ReadChunks(std::function<bool(ChunkId*, long, int)> func, int arg)
76{

Callers

nothing calls this directly

Calls 4

EqualsToMethod · 0.80
GetCurrentPositionMethod · 0.80
SeekMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected