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

Method Load

src/External/CascLib/src/CascRootFile_OW.cpp:303–366  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

301 }
302
303 DWORD Load(TCascStorage * hs, CASC_CSV & Csv, size_t nFileNameIndex, size_t nCKeyIndex)
304 {
305 PCASC_CKEY_ENTRY pCKeyEntry;
306 size_t nFileCount;
307 DWORD dwErrCode = ERROR_SUCCESS;
308 BYTE CKey[MD5_HASH_SIZE];
309
310 CASCLIB_UNUSED(hs);
311
312 // Keep loading every line until there is something
313 while(Csv.LoadNextLine())
314 {
315 const CASC_CSV_COLUMN & FileName = Csv[CSV_ZERO][nFileNameIndex];
316 const CASC_CSV_COLUMN & CKeyStr = Csv[CSV_ZERO][nCKeyIndex];
317
318 // Retrieve the file name and the content key
319 if(FileName.szValue && CKeyStr.szValue && CKeyStr.nLength == MD5_STRING_SIZE)
320 {
321 // Convert the string CKey to binary
322 if(BinaryFromString(CKeyStr.szValue, MD5_STRING_SIZE, CKey) == ERROR_SUCCESS)
323 {
324 // Find the item in the tree
325 if((pCKeyEntry = FindCKeyEntry_CKey(hs, CKey)) != NULL)
326 {
327 // Insert the file name and the CKey into the tree
328 FileTree.InsertByName(pCKeyEntry, FileName.szValue);
329 }
330 }
331 }
332 }
333
334 // Get the total file count that we loaded so far
335 nFileCount = FileTree.GetCount();
336
337 // Parse Content Manifest Files (.cmf)
338 for(size_t i = 0; i < nFileCount && dwErrCode == ERROR_SUCCESS; i++)
339 {
340 PCASC_FILE_NODE pFileNode;
341 const char * szExtension;
342 char szFileName[MAX_PATH];
343
344 // Get the n-th file
345 pFileNode = (PCASC_FILE_NODE)FileTree.PathAt(szFileName, _countof(szFileName), i);
346 if(pFileNode != NULL)
347 {
348 if(IsManifestFolderName(szFileName, "Manifest", 8) || IsManifestFolderName(szFileName, "TactManifest", 12))
349 {
350 // Retrieve the file extension
351 szExtension = GetFileExtension(szFileName);
352
353 // Check for content manifest files
354 if(!_stricmp(szExtension, ".cmf"))
355 {
356 dwErrCode = LoadContentManifestFile(hs, FileTree, pFileNode->pCKeyEntry, szFileName);
357 }
358 else if(!_stricmp(szExtension, ".apm"))
359 {
360 dwErrCode = LoadApplicationPackageManifestFile(hs, FileTree, pFileNode->pCKeyEntry, szFileName);

Callers 1

Calls 10

BinaryFromStringFunction · 0.85
FindCKeyEntry_CKeyFunction · 0.85
IsManifestFolderNameFunction · 0.85
GetFileExtensionFunction · 0.85
LoadContentManifestFileFunction · 0.85
LoadNextLineMethod · 0.80
InsertByNameMethod · 0.80
GetCountMethod · 0.80
PathAtMethod · 0.80

Tested by

no test coverage detected