| 732 | } |
| 733 | |
| 734 | static DWORD LoadArchiveIndexFiles(TCascStorage * hs) |
| 735 | { |
| 736 | CASC_BLOB FileData; |
| 737 | size_t nArchiveCount = (hs->ArchivesKey.cbData / MD5_HASH_SIZE); |
| 738 | DWORD dwErrCode = ERROR_SUCCESS; |
| 739 | |
| 740 | // Create the array object for the indices |
| 741 | dwErrCode = hs->IndexArray.Create(sizeof(CASC_EKEY_ENTRY), 0x10000); |
| 742 | if(dwErrCode != ERROR_SUCCESS) |
| 743 | return dwErrCode; |
| 744 | |
| 745 | // Load all the indices |
| 746 | for(size_t i = 0; i < nArchiveCount; i++) |
| 747 | { |
| 748 | CASC_PATH<TCHAR> LocalPath; |
| 749 | LPBYTE pbIndexHash = hs->ArchivesKey.pbData + (i * MD5_HASH_SIZE); |
| 750 | |
| 751 | // Inform the user about what we are doing |
| 752 | if(InvokeProgressCallback(hs, "Downloading archive indexes", NULL, (DWORD)(i), (DWORD)(nArchiveCount))) |
| 753 | { |
| 754 | dwErrCode = ERROR_CANCELLED; |
| 755 | break; |
| 756 | } |
| 757 | |
| 758 | // Fetch and parse the archive index |
| 759 | dwErrCode = FetchCascFile(hs, PathTypeData, pbIndexHash, _T(".index"), LocalPath); |
| 760 | if(dwErrCode == ERROR_SUCCESS) |
| 761 | { |
| 762 | // Load the index file to memory |
| 763 | if((dwErrCode = LoadFileToMemory(LocalPath, FileData)) == ERROR_SUCCESS) |
| 764 | { |
| 765 | dwErrCode = LoadArchiveIndexFile(hs, FileData.pbData, FileData.cbData, i); |
| 766 | } |
| 767 | } |
| 768 | |
| 769 | // Break if an error |
| 770 | if(dwErrCode != ERROR_SUCCESS) |
| 771 | break; |
| 772 | } |
| 773 | |
| 774 | // Build map of EKey -> CASC_EKEY_ENTRY |
| 775 | if(dwErrCode == ERROR_SUCCESS) |
| 776 | dwErrCode = BuildMapOfArchiveIndices(hs); |
| 777 | return dwErrCode; |
| 778 | } |
| 779 | |
| 780 | //----------------------------------------------------------------------------- |
| 781 | // Public functions |
no test coverage detected