MCPcopy Create free account
hub / github.com/diasurgical/devilution / DoMPQSearch

Function DoMPQSearch

3rdParty/StormLib/src/SFileFindFile.cpp:335–365  ·  view source on GitHub ↗

Performs one MPQ search

Source from the content-addressed store, hash-verified

333
334// Performs one MPQ search
335static int DoMPQSearch(TMPQSearch * hs, SFILE_FIND_DATA * lpFindFileData)
336{
337 TMPQArchive * ha = hs->ha;
338 int nError;
339
340 // Start searching with base MPQ
341 while(ha != NULL)
342 {
343 // If the archive has hash table, we need to use hash table
344 // in order to catch hash table index and file locale.
345 // Note: If multiple hash table entries, point to the same block entry,
346 // we need, to report them all
347 nError = (ha->pHashTable != NULL) ? DoMPQSearch_HashTable(hs, lpFindFileData, ha)
348 : DoMPQSearch_FileTable(hs, lpFindFileData, ha);
349 if(nError == ERROR_SUCCESS)
350 return nError;
351
352 // If there is no more patches in the chain, stop it.
353 // This also keeps hs->ha non-NULL, which is required
354 // for freeing the handle later
355 if(ha->haPatch == NULL)
356 break;
357
358 // Move to the next patch in the patch chain
359 hs->ha = ha = ha->haPatch;
360 hs->dwNextIndex = 0;
361 }
362
363 // No more files found, return error
364 return ERROR_NO_MORE_FILES;
365}
366
367static void FreeMPQSearch(TMPQSearch *& hs)
368{

Callers 2

SFileFindFirstFileFunction · 0.85
SFileFindNextFileFunction · 0.85

Calls 2

DoMPQSearch_HashTableFunction · 0.85
DoMPQSearch_FileTableFunction · 0.85

Tested by

no test coverage detected