Search for files
| 518 | |
| 519 | // Search for files |
| 520 | PCASC_CKEY_ENTRY Search(TCascSearch * pSearch, PCASC_FIND_DATA pFindData) |
| 521 | { |
| 522 | // If we have a listfile, we'll feed the listfile entries to the file tree |
| 523 | if(pSearch->pCache != NULL && pSearch->bListFileUsed == false) |
| 524 | { |
| 525 | PCASC_FILE_NODE pFileNode; |
| 526 | ULONGLONG FileNameHash; |
| 527 | size_t nLength; |
| 528 | DWORD FileDataId = CASC_INVALID_ID; |
| 529 | char szFileName[MAX_PATH]; |
| 530 | |
| 531 | if(RootFormat == RootFormatWoW_v2) |
| 532 | { |
| 533 | // Keep going through the listfile |
| 534 | for(;;) |
| 535 | { |
| 536 | // Retrieve the next line from the list file. Ignore lines that are too long to fit in the buffer |
| 537 | nLength = ListFile_GetNext(pSearch->pCache, szFileName, _countof(szFileName), &FileDataId); |
| 538 | if(nLength == 0) |
| 539 | { |
| 540 | if(GetCascError() == ERROR_INSUFFICIENT_BUFFER) |
| 541 | continue; |
| 542 | break; |
| 543 | } |
| 544 | |
| 545 | // Try to verify the file name by hash |
| 546 | VerifyAndLogFileName(szFileName, FileDataId); |
| 547 | |
| 548 | // |
| 549 | // Several files were renamed around WoW build 50893 (10.1.7). Example: |
| 550 | // |
| 551 | // * 2965132; interface/icons/inv_helm_armor_explorer_d_01.blp file name hash = 0x770b8d2dc4d940aa |
| 552 | // * 2965132; interface/icons/inv_armor_explorer_d_01_helm.blp file name hash = 0xf47ec17f4a1e49a2 |
| 553 | // |
| 554 | // For that reason, we also need to check whether the file name hash matches |
| 555 | // |
| 556 | |
| 557 | // BREAKIF(FileDataId == 2965132); |
| 558 | |
| 559 | if((pFileNode = FileTree.FindById(FileDataId)) != NULL) |
| 560 | { |
| 561 | if(pFileNode->NameLength == 0) |
| 562 | { |
| 563 | if(pFileNode->FileNameHash && pFileNode->FileNameHash != CalcFileNameHash(szFileName)) |
| 564 | continue; |
| 565 | FileTree.SetNodeFileName(pFileNode, szFileName); |
| 566 | } |
| 567 | } |
| 568 | } |
| 569 | } |
| 570 | else |
| 571 | { |
| 572 | // Keep going through the listfile |
| 573 | for(;;) |
| 574 | { |
| 575 | // Retrieve the next line from the list file. Ignore lines that are too long to fit in the buffer |
| 576 | nLength = ListFile_GetNextLine(pSearch->pCache, szFileName, _countof(szFileName)); |
| 577 | if(nLength == 0) |
nothing calls this directly
no test coverage detected