MCPcopy Create free account
hub / github.com/HertzDevil/0CC-FamiTracker / ReadBlock

Method ReadBlock

Source/DocumentFile.cpp:215–247  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

213}
214
215bool CDocumentFile::ReadBlock()
216{
217 m_iBlockPointer = 0;
218
219 m_cBlockID.fill(0); // // //
220
221 int BytesRead = Read(reinterpret_cast<unsigned char *>(m_cBlockID.data()), std::size(m_cBlockID) * sizeof(char));
222 Read(reinterpret_cast<unsigned char *>(&m_iBlockVersion), sizeof(m_iBlockVersion));
223 Read(reinterpret_cast<unsigned char *>(&m_iBlockSize), sizeof(m_iBlockSize));
224
225 if (m_iBlockSize > 50000000) {
226 // File is probably corrupt
227 m_cBlockID.fill(0); // // //
228 return true;
229 }
230
231 m_pBlockData = std::vector<unsigned char>(m_iBlockSize); // // //
232 if (Read(m_pBlockData.data(), m_iBlockSize) == FILE_END_ID.size()) // // //
233 if (array_view<char> {m_cBlockID.data(), FILE_END_ID.size()} == FILE_END_ID)
234 m_bFileDone = true;
235
236 if (BytesRead == 0)
237 m_bFileDone = true;
238/*
239 if (GetPosition() == GetLength() && !m_bFileDone) {
240 // Parts of file is missing
241 m_bIncomplete = true;
242 m_cBlockID.fill(0);
243 return true;
244 }
245*/
246 return false;
247}
248
249const char *CDocumentFile::GetBlockHeaderID() const // // //
250{

Callers 1

LoadMethod · 0.80

Calls 4

sizeFunction · 0.85
fillMethod · 0.80
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected