From 927bac4d58db93764c272abedd4a7b263ed66a9c Mon Sep 17 00:00:00 2001 From: Justin F Date: Thu, 1 Jun 2023 22:36:02 -0500 Subject: Add listfile from memory --- src/SFileListFile.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++++ src/StormLib.h | 1 + 2 files changed, 46 insertions(+) (limited to 'src') diff --git a/src/SFileListFile.cpp b/src/SFileListFile.cpp index 2a3f02a..efad14e 100644 --- a/src/SFileListFile.cpp +++ b/src/SFileListFile.cpp @@ -558,6 +558,25 @@ static DWORD SFileAddArbitraryListFile( return (pCache != NULL) ? ERROR_SUCCESS : ERROR_FILE_CORRUPT; } +static int SFileAddArbitraryListFile( + TMPQArchive * ha, + const char ** listFileEntries, + DWORD dwEntryCount) +{ + if(listFileEntries != NULL && dwEntryCount > 0) + { + // Get the next line + for (DWORD dwListFileNum=0; dwListFileNum 0) ? ERROR_SUCCESS : ERROR_INVALID_PARAMETER; +} + static DWORD SFileAddInternalListFile( TMPQArchive * ha, HANDLE hMpq) @@ -662,6 +681,32 @@ DWORD WINAPI SFileAddListFile(HANDLE hMpq, const TCHAR * szListFile) return dwErrCode; } +DWORD WINAPI SFileAddListFileEntries(HANDLE hMpq, const char ** listFileEntries, DWORD dwEntryCount) +{ + TMPQArchive * ha = (TMPQArchive *)hMpq; + DWORD dwErrCode = ERROR_SUCCESS; + + // Add the listfile for each MPQ in the patch chain + while(ha != NULL) + { + if(listFileEntries != NULL && dwEntryCount > 0) + dwErrCode = SFileAddArbitraryListFile(ha, listFileEntries, dwEntryCount); + else + dwErrCode = SFileAddInternalListFile(ha, hMpq); + + // Also, add three special files to the listfile: + // (listfile) itself, (attributes) and (signature) + SListFileCreateNodeForAllLocales(ha, LISTFILE_NAME); + SListFileCreateNodeForAllLocales(ha, SIGNATURE_NAME); + SListFileCreateNodeForAllLocales(ha, ATTRIBUTES_NAME); + + // Move to the next archive in the chain + ha = ha->haPatch; + } + + return dwErrCode; +} + //----------------------------------------------------------------------------- // Enumerating files in listfile diff --git a/src/StormLib.h b/src/StormLib.h index e45f99d..07408b2 100644 --- a/src/StormLib.h +++ b/src/StormLib.h @@ -1025,6 +1025,7 @@ bool WINAPI SFileCloseArchive(HANDLE hMpq); // so you can use this API to combining more listfiles. // Note that this function is internally called by SFileFindFirstFile DWORD WINAPI SFileAddListFile(HANDLE hMpq, const TCHAR * szListFile); +DWORD WINAPI SFileAddListFileEntries(HANDLE hMpq, const char ** listFileEntries, DWORD dwEntryCount); // Archive compacting bool WINAPI SFileSetCompactCallback(HANDLE hMpq, SFILE_COMPACT_CALLBACK CompactCB, void * pvUserData); -- cgit v1.2.3