static int TestOpenStorage_EnumFiles(const TCHAR * szStorage, const TCHAR * szListFile = NULL) { CASC_FIND_DATA FindData; HANDLE hStorage; HANDLE hFind; DWORD dwTotalFiles = 0; DWORD dwFoundFiles = 0; bool bFileFound = true; int nError = ERROR_SUCCESS; // Open the storage directory if(!CascOpenStorage(szStorage, 0, &hStorage)) { assert(GetLastError() != ERROR_SUCCESS); nError = GetLastError(); } if(nError == ERROR_SUCCESS) { // Retrieve the total number of files CascGetStorageInfo(hStorage, CascStorageFileCount, &dwTotalFiles, sizeof(dwTotalFiles), NULL); // Start finding hFind = CascFindFirstFile(hStorage, "*", &FindData, szListFile); if(hFind != NULL) { while(bFileFound) { // Extract the file // printf("%s\n", FindData.szFileName); dwFoundFiles++; // Find the next file in CASC bFileFound = CascFindNextFile(hFind, &FindData); } // Just a testing call - must fail CascFindNextFile(hFind, &FindData); // Close the search handle CascFindClose(hFind); } } // Close storage and return if(hStorage != NULL) CascCloseStorage(hStorage); return nError; }
static int TestOpenStorage_EnumFiles(const TCHAR * szStorage, const TCHAR * szListFile) { CASC_FIND_DATA FindData; HANDLE hStorage; HANDLE hFind; bool bFileFound = true; int nError = ERROR_SUCCESS; // Open the storage directory if(!CascOpenStorage(szStorage, 0, &hStorage)) { assert(GetLastError() != ERROR_SUCCESS); nError = GetLastError(); } if(nError == ERROR_SUCCESS) { hFind = CascFindFirstFile(hStorage, "*", &FindData, szListFile); if(hFind != NULL) { while(bFileFound) { // Extract the file printf("%s\n", FindData.szFileName); // Find the next file in CASC bFileFound = CascFindNextFile(hFind, &FindData); } // Just a testing call - must fail CascFindNextFile(hFind, &FindData); // Close the search handle CascFindClose(hFind); } } // Close storage and return if(hStorage != NULL) CascCloseStorage(hStorage); return nError; }
static int TestOpenStorage_ExtractFiles(const TCHAR * szStorage, const TCHAR * szTargetDir, const TCHAR * szListFile) { CASC_FIND_DATA FindData; HANDLE hStorage; HANDLE hFind; bool bFileFound = true; int nError = ERROR_SUCCESS; // Open the storage directory if(!CascOpenStorage(szStorage, 0, &hStorage)) { assert(GetLastError() != ERROR_SUCCESS); nError = GetLastError(); } if(nError == ERROR_SUCCESS) { hFind = CascFindFirstFile(hStorage, "*", &FindData, szListFile); if(hFind != INVALID_HANDLE_VALUE) { while(bFileFound) { // Extract the file printf("Extracting: %s ...", FindData.szFileName); nError = ExtractFile(hStorage, FindData.szFileName, szTargetDir, FindData.dwLocaleFlags); printf((nError == ERROR_SUCCESS) ? "OK\n" : "Failed\n"); // Find the next file in CASC bFileFound = CascFindNextFile(hFind, &FindData); } // Close the search handle CascFindClose(hFind); } } // Close storage and return if(hStorage != NULL) CascCloseStorage(hStorage); return nError; }