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

Method Load

src/External/CascLib/src/CascRootFile_MNDX.cpp:2690–2816  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2688 }
2689
2690 DWORD Load(const FILE_MNDX_HEADER & MndxHeader, LPBYTE pbRootFile, LPBYTE pbRootEnd)
2691 {
2692 TMndxMarFile * pMarFile;
2693 FILE_MAR_INFO MarInfo;
2694 size_t nFilePointer = 0;
2695 DWORD i;
2696 DWORD dwErrCode = ERROR_SUCCESS;
2697
2698 // Copy the header into the MNDX info
2699 MndxInfo.HeaderVersion = MndxHeader.HeaderVersion;
2700 MndxInfo.FormatVersion = MndxHeader.FormatVersion;
2701 nFilePointer += sizeof(FILE_MNDX_HEADER);
2702
2703 // Header version 2 has 2 extra fields that we need to load
2704 if(MndxInfo.HeaderVersion == 2)
2705 {
2706 if(!CaptureData(pbRootFile + nFilePointer, pbRootEnd, &MndxInfo.field_1C, sizeof(DWORD) + sizeof(DWORD)))
2707 return ERROR_FILE_CORRUPT;
2708 nFilePointer += sizeof(DWORD) + sizeof(DWORD);
2709 }
2710
2711 // Load the rest of the file header
2712 if(!CaptureData(pbRootFile + nFilePointer, pbRootEnd, &MndxInfo.MarInfoOffset, 0x1C))
2713 return ERROR_FILE_CORRUPT;
2714
2715 // Verify the structure
2716 if(MndxInfo.MarInfoCount > MAR_COUNT || MndxInfo.MarInfoSize != sizeof(FILE_MAR_INFO))
2717 return ERROR_FILE_CORRUPT;
2718
2719 // Load all MAR infos
2720 for(i = 0; i < MndxInfo.MarInfoCount; i++)
2721 {
2722 // Capture the n-th MAR info
2723 nFilePointer = MndxInfo.MarInfoOffset + (MndxInfo.MarInfoSize * i);
2724 if(!CaptureData(pbRootFile + nFilePointer, pbRootEnd, &MarInfo, sizeof(FILE_MAR_INFO)))
2725 return ERROR_FILE_CORRUPT;
2726
2727 // Allocate MAR_FILE structure
2728 pMarFile = new TMndxMarFile();
2729 if(pMarFile == NULL)
2730 {
2731 dwErrCode = ERROR_NOT_ENOUGH_MEMORY;
2732 break;
2733 }
2734
2735 // Create the database from the MAR data
2736 dwErrCode = pMarFile->LoadRootData(MarInfo, pbRootFile, pbRootEnd);
2737 if(dwErrCode != ERROR_SUCCESS)
2738 break;
2739
2740 // Assign the MAR file to the MNDX info structure
2741 MndxInfo.MarFiles[i] = pMarFile;
2742 }
2743
2744 // All three MAR files must be loaded
2745 // HOTS: 00E9503B
2746 if(dwErrCode == ERROR_SUCCESS)
2747 {

Callers 3

LoadRootDataMethod · 0.45
LoadMethod · 0.45
RootHandler_CreateMNDXFunction · 0.45

Calls 3

CaptureDataFunction · 0.85
LoadRootDataMethod · 0.80
GetFileNameCountMethod · 0.80

Tested by

no test coverage detected