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

Function GetFileSpanInfo

src/External/CascLib/src/CascReadFile.cpp:706–740  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

704}
705
706static bool GetFileSpanInfo(TCascFile * hf, void * pvFileInfo, size_t cbFileInfo, size_t * pcbLengthNeeded)
707{
708 PCASC_FILE_SPAN_INFO pFileInfo;
709 PCASC_FILE_SPAN pFileSpan = hf->pFileSpan;
710 PCASC_CKEY_ENTRY pCKeyEntry = hf->pCKeyEntry;
711 DWORD dwErrCode = ERROR_SUCCESS;
712
713 // Make sure that the file spans are loaded
714 dwErrCode = EnsureFileSpanFramesLoaded(hf);
715 if(dwErrCode != ERROR_SUCCESS)
716 {
717 SetCascError(dwErrCode);
718 return false;
719 }
720
721 // Verify whether we have enough space in the buffer
722 pFileInfo = (PCASC_FILE_SPAN_INFO)ProbeOutputBuffer(pvFileInfo, cbFileInfo, sizeof(CASC_FILE_SPAN_INFO) * hf->SpanCount, pcbLengthNeeded);
723 if(pFileInfo != NULL)
724 {
725 // Copy all file spans
726 for(DWORD i = 0; i < hf->SpanCount; i++, pFileInfo++, pFileSpan++, pCKeyEntry++)
727 {
728 CopyMemory16(pFileInfo->CKey, pCKeyEntry->CKey);
729 CopyMemory16(pFileInfo->EKey, pCKeyEntry->EKey);
730 pFileInfo->StartOffset = pFileSpan->StartOffset;
731 pFileInfo->EndOffset = pFileSpan->EndOffset;
732 pFileInfo->ArchiveIndex = pFileSpan->ArchiveIndex;
733 pFileInfo->ArchiveOffs = pFileSpan->ArchiveOffs;
734 pFileInfo->HeaderSize = pFileSpan->HeaderSize;
735 pFileInfo->FrameCount = pFileSpan->FrameCount;
736 }
737 }
738
739 return (pFileInfo != NULL);
740}
741
742
743// Reads the file data from cache. Returns the number of bytes read

Callers 1

CascGetFileInfoFunction · 0.70

Calls 4

SetCascErrorFunction · 0.85
ProbeOutputBufferFunction · 0.85
CopyMemory16Function · 0.85

Tested by

no test coverage detected