diff options
author | Justin F <forsbergjj@gmail.com> | 2023-06-01 22:36:02 -0500 |
---|---|---|
committer | Justin F <forsbergjj@gmail.com> | 2023-06-01 22:36:02 -0500 |
commit | 927bac4d58db93764c272abedd4a7b263ed66a9c (patch) | |
tree | 2bc61b63f1c996aaee9c75374f4e77e74bae8fde /src/SFileListFile.cpp | |
parent | 33e6a2bdfec872c31bfd7ce2899012c129894f7e (diff) |
Add listfile from memory
Diffstat (limited to 'src/SFileListFile.cpp')
-rw-r--r-- | src/SFileListFile.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
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<dwEntryCount; dwListFileNum++)
+ {
+ const char* listFileEntry = listFileEntries[dwListFileNum];
+ if ( listFileEntry != NULL )
+ SListFileCreateNodeForAllLocales(ha, listFileEntry);
+ }
+ }
+
+ return (listFileEntries != NULL && dwEntryCount > 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
|