| 46 | } |
| 47 | |
| 48 | bool 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 | |
| 75 | bool ChunkReader::ReadChunks(std::function<bool(ChunkId*, long, int)> func, int arg) |
| 76 | { |
nothing calls this directly
no test coverage detected