From 60ef0346ba14b7153c9efd40d0aa6dd01d1d2671 Mon Sep 17 00:00:00 2001 From: Ladislav Date: Mon, 16 Dec 2013 12:18:32 +0100 Subject: + Fixed bugs in listfile search --- test/Test.cpp | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) (limited to 'test/Test.cpp') diff --git a/test/Test.cpp b/test/Test.cpp index 7566fbe..7487cad 100644 --- a/test/Test.cpp +++ b/test/Test.cpp @@ -260,6 +260,7 @@ static const char * GetShortPlainName(const char * szFileName) // If the name is still too long, cut it if((szPlainEnd - szPlainName) > 50) szPlainName = szPlainEnd - 50; + return szPlainName; } @@ -1629,6 +1630,30 @@ static int TestOpenLocalFile(const char * szPlainName) return ERROR_SUCCESS; } +static int TestSearchListFile(const char * szPlainName) +{ + SFILE_FIND_DATA sf; + TLogHelper Logger("SearchListFile", szPlainName); + HANDLE hFind; + char szFullPath[MAX_PATH]; + int nFileCount = 0; + + CreateFullPathName(szFullPath, szMpqSubDir, szPlainName); + hFind = SListFileFindFirstFile(NULL, szFullPath, "*", &sf); + if(hFind != NULL) + { + for(;;) + { + Logger.PrintProgress("Found file (%04u): %s", nFileCount++, GetShortPlainName(sf.cFileName)); + if(!SListFileFindNextFile(hFind, &sf)) + break; + } + + SListFileFindClose(hFind); + } + return ERROR_SUCCESS; +} + // static int TestPartFileRead(const char * szPlainName) { @@ -2861,8 +2886,8 @@ int main(int argc, char * argv[]) nError = InitializeMpqDirectory(argv, argc); // Not a test, but rather a tool for creating links to duplicated files - if(nError == ERROR_SUCCESS) - nError = FindFilePairs(ForEachFile_CreateArchiveLink, "2004 - WoW\\16965", "2004 - WoW\\17658"); +// if(nError == ERROR_SUCCESS) +// nError = FindFilePairs(ForEachFile_CreateArchiveLink, "2004 - WoW\\06080", "2004 - WoW\\06299"); // Search all testing archives and verify their SHA1 hash if(nError == ERROR_SUCCESS) @@ -2872,6 +2897,10 @@ int main(int argc, char * argv[]) if(nError == ERROR_SUCCESS) nError = TestOpenLocalFile("ListFile_Blizzard.txt"); + // Search in listfile + if(nError == ERROR_SUCCESS) + nError = TestSearchListFile("ListFile_Blizzard.txt"); + // Test reading partial file if(nError == ERROR_SUCCESS) nError = TestPartFileRead("MPQ_2009_v2_WoW_patch.MPQ.part"); @@ -2880,6 +2909,10 @@ int main(int argc, char * argv[]) if(nError == ERROR_SUCCESS) nError = TestOpenFile_OpenById("MPQ_1997_v1_Diablo1_DIABDAT.MPQ"); + // Open an empty archive (found in WoW cache - it's just a header) + if(nError == ERROR_SUCCESS) + nError = TestOpenArchive("WoW-1.2.4-to-1.3.0-enGB-patch.exe"); + // Open an empty archive (found in WoW cache - it's just a header) if(nError == ERROR_SUCCESS) nError = TestOpenArchive("MPQ_2012_v2_EmptyMpq.MPQ"); -- cgit v1.2.3