| 738 | } |
| 739 | |
| 740 | static DWORD Storage_EnumFiles(TLogHelper & LogHelper, TEST_PARAMS & Params) |
| 741 | { |
| 742 | PCASC_FIND_DATA_ARRAY pFiles; |
| 743 | PCASC_FIND_DATA pFindData; |
| 744 | CASC_FIND_DATA cf; |
| 745 | MD5_CTX NameHashCtx; |
| 746 | MD5_CTX DataHashCtx; |
| 747 | LPCTSTR szListFile = GetTheProperListfile(Params.hStorage, Params.szListFile); |
| 748 | LPCSTR szNameHash; |
| 749 | LPCSTR szDataHash; |
| 750 | HANDLE hStorage = Params.hStorage; |
| 751 | HANDLE hFind; |
| 752 | size_t cbToAllocate = 0; |
| 753 | DWORD dwTotalFileCount = 0; |
| 754 | DWORD dwFileIndex = 0; |
| 755 | DWORD dwErrCode = ERROR_SUCCESS; |
| 756 | char szHashString[MD5_STRING_SIZE+1]; |
| 757 | char szTotalBytes[0x20]; |
| 758 | // char szShortName[SHORT_NAME_SIZE]; |
| 759 | bool bFileFound = true; |
| 760 | |
| 761 | // Create the output file for dumping all file names |
| 762 | //Params.fp1 = OpenOutputTextFile(hStorage, "\\list-%s-%u-001.txt"); |
| 763 | |
| 764 | // Dump the storage |
| 765 | // LogHelper.PrintProgress("Dumping storage ..."); |
| 766 | // CascDumpStorage(hStorage, "E:\\storage-dump.txt"); |
| 767 | |
| 768 | // Retrieve the total number of files |
| 769 | CascGetStorageInfo(hStorage, CascStorageTotalFileCount, &dwTotalFileCount, sizeof(dwTotalFileCount), NULL); |
| 770 | LogHelper.TotalFiles = dwTotalFileCount; |
| 771 | |
| 772 | // Retrieve the tags |
| 773 | TestStorageGetTagInfo(hStorage); |
| 774 | TestStorageGetName(hStorage); |
| 775 | |
| 776 | // Init both hashers |
| 777 | MD5_Init(&NameHashCtx); |
| 778 | MD5_Init(&DataHashCtx); |
| 779 | |
| 780 | #ifdef CASCLIB_WRITE_VERIFIED_FILENAMES |
| 781 | Params.bCheckFileData = 0; |
| 782 | #endif |
| 783 | |
| 784 | // Allocate the structure holding all file information |
| 785 | cbToAllocate = sizeof(CASC_FIND_DATA_ARRAY) + (dwTotalFileCount * sizeof(CASC_FIND_DATA)); |
| 786 | if((pFiles = (PCASC_FIND_DATA_ARRAY)(CASC_ALLOC<BYTE>(cbToAllocate))) != NULL) |
| 787 | { |
| 788 | // Init the structure |
| 789 | pFiles->pTestParams = &Params; |
| 790 | pFiles->pLogHelper = &LogHelper; |
| 791 | pFiles->hStorage = hStorage; |
| 792 | pFiles->ItemIndex = 0; |
| 793 | pFiles->ItemCount = 0; |
| 794 | |
| 795 | // Iterate over the storage |
| 796 | LogHelper.PrintProgress("Searching storage ..."); |
| 797 | hFind = CascFindFirstFile(hStorage, "*", &pFiles->cf[dwFileIndex], szListFile); |
no test coverage detected