MCPcopy Create free account
hub / github.com/Scobalula/Greyhound / LoadFileSpanFrames

Function LoadFileSpanFrames

src/External/CascLib/src/CascReadFile.cpp:476–519  ·  view source on GitHub ↗

Loads all file spans to memory

Source from the content-addressed store, hash-verified

474
475// Loads all file spans to memory
476static DWORD LoadFileSpanFrames(TCascFile * hf)
477{
478 PCASC_CKEY_ENTRY pCKeyEntry = hf->pCKeyEntry;
479 PCASC_FILE_SPAN pFileSpan = hf->pFileSpan;
480 DWORD dwErrCode = ERROR_SUCCESS;
481
482 // If the ContentSize/EncodedSize is still unknown, we need to get it from the file frames
483 if(hf->ContentSize == CASC_INVALID_SIZE64 || hf->EncodedSize == CASC_INVALID_SIZE64)
484 {
485 // Set initially to zero
486 hf->ContentSize = 0;
487 hf->EncodedSize = 0;
488
489 // Load file frames for all spans
490 for(DWORD i = 0; i < hf->SpanCount; i++, pCKeyEntry++, pFileSpan++)
491 {
492 // Init the range of the file span
493 pFileSpan->StartOffset = hf->ContentSize;
494 pFileSpan->EndOffset = hf->ContentSize;
495
496 // Load the frames of the file span
497 dwErrCode = LoadSpanFrames(hf, pFileSpan, pCKeyEntry);
498 if(dwErrCode != ERROR_SUCCESS)
499 break;
500
501 hf->ContentSize += pCKeyEntry->ContentSize;
502 hf->EncodedSize += pCKeyEntry->EncodedSize;
503 pFileSpan->EndOffset = hf->ContentSize;
504 }
505 }
506 else
507 {
508 // Load file frames for all spans
509 for(DWORD i = 0; i < hf->SpanCount; i++, pCKeyEntry++, pFileSpan++)
510 {
511 // Load the frames of the file span
512 dwErrCode = LoadSpanFrames(hf, pFileSpan, pCKeyEntry);
513 if(dwErrCode != ERROR_SUCCESS)
514 break;
515 }
516 }
517
518 return dwErrCode;
519}
520
521static DWORD EnsureFileSpanFramesLoaded(TCascFile * hf)
522{

Callers 1

Calls 1

LoadSpanFramesFunction · 0.85

Tested by

no test coverage detected