aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZezula Ladislav <ladislav.zezula@avast.com>2017-08-17 10:20:11 +0200
committerZezula Ladislav <ladislav.zezula@avast.com>2017-08-17 10:20:11 +0200
commitadac4aa0f586c7aa2a3c19aa4e687d827dc86195 (patch)
treeb3f5243778c5a0fb53945364826de356a8146871
parent2576998c8841c2d72d7d3fd9cb4f99aa1fbc2cd1 (diff)
+ Fixed issue "Internal Files Creation Settings #96"
-rw-r--r--src/SFileAttributes.cpp2
-rw-r--r--src/SFileCreateArchive.cpp8
-rw-r--r--src/SFileListFile.cpp2
-rw-r--r--src/StormLib.h8
-rw-r--r--test/StormTest.cpp14
5 files changed, 19 insertions, 15 deletions
diff --git a/src/SFileAttributes.cpp b/src/SFileAttributes.cpp
index d58426c..f57f62c 100644
--- a/src/SFileAttributes.cpp
+++ b/src/SFileAttributes.cpp
@@ -429,7 +429,7 @@ int SAttrFileSaveToMpq(TMPQArchive * ha)
if(pbAttrFile != NULL)
{
// Determine the real flags for (attributes)
- if(ha->dwFileFlags2 == MPQ_FILE_EXISTS)
+ if(ha->dwFileFlags2 == MPQ_FILE_DEFAULT_INTERNAL)
ha->dwFileFlags2 = GetDefaultSpecialFileFlags(cbAttrFile, ha->pHeader->wFormatVersion);
// Create the attributes file in the MPQ
diff --git a/src/SFileCreateArchive.cpp b/src/SFileCreateArchive.cpp
index 47354fe..de4ab36 100644
--- a/src/SFileCreateArchive.cpp
+++ b/src/SFileCreateArchive.cpp
@@ -78,9 +78,9 @@ bool WINAPI SFileCreateArchive(const TCHAR * szMpqName, DWORD dwCreateFlags, DWO
CreateInfo.cbSize = sizeof(SFILE_CREATE_MPQ);
CreateInfo.dwMpqVersion = (dwCreateFlags & MPQ_CREATE_ARCHIVE_VMASK) >> FLAGS_TO_FORMAT_SHIFT;
CreateInfo.dwStreamFlags = STREAM_PROVIDER_FLAT | BASE_PROVIDER_FILE;
- CreateInfo.dwFileFlags1 = (dwCreateFlags & MPQ_CREATE_LISTFILE) ? MPQ_FILE_EXISTS : 0;
- CreateInfo.dwFileFlags2 = (dwCreateFlags & MPQ_CREATE_ATTRIBUTES) ? MPQ_FILE_EXISTS : 0;
- CreateInfo.dwFileFlags3 = (dwCreateFlags & MPQ_CREATE_SIGNATURE) ? MPQ_FILE_EXISTS : 0;
+ CreateInfo.dwFileFlags1 = (dwCreateFlags & MPQ_CREATE_LISTFILE) ? MPQ_FILE_DEFAULT_INTERNAL : 0;
+ CreateInfo.dwFileFlags2 = (dwCreateFlags & MPQ_CREATE_ATTRIBUTES) ? MPQ_FILE_DEFAULT_INTERNAL : 0;
+ CreateInfo.dwFileFlags3 = (dwCreateFlags & MPQ_CREATE_SIGNATURE) ? MPQ_FILE_DEFAULT_INTERNAL : 0;
CreateInfo.dwAttrFlags = (dwCreateFlags & MPQ_CREATE_ATTRIBUTES) ? (MPQ_ATTRIBUTE_CRC32 | MPQ_ATTRIBUTE_FILETIME | MPQ_ATTRIBUTE_MD5) : 0;
CreateInfo.dwSectorSize = (CreateInfo.dwMpqVersion >= MPQ_FORMAT_VERSION_3) ? 0x4000 : 0x1000;
CreateInfo.dwRawChunkSize = (CreateInfo.dwMpqVersion >= MPQ_FORMAT_VERSION_4) ? 0x4000 : 0;
@@ -92,7 +92,7 @@ bool WINAPI SFileCreateArchive(const TCHAR * szMpqName, DWORD dwCreateFlags, DWO
// Backward compatibility: SFileCreateArchive always used to add (listfile)
// We would break loads of applications if we change that
- CreateInfo.dwFileFlags1 = MPQ_FILE_EXISTS;
+ CreateInfo.dwFileFlags1 = MPQ_FILE_DEFAULT_INTERNAL;
// Let the main function create the archive
return SFileCreateArchive2(szMpqName, &CreateInfo, phMpq);
diff --git a/src/SFileListFile.cpp b/src/SFileListFile.cpp
index 00fa9fa..588eca4 100644
--- a/src/SFileListFile.cpp
+++ b/src/SFileListFile.cpp
@@ -385,7 +385,7 @@ int SListFileSaveToMpq(TMPQArchive * ha)
if(pbListFile != NULL)
{
// Determine the real flags for (listfile)
- if(ha->dwFileFlags1 == MPQ_FILE_EXISTS)
+ if(ha->dwFileFlags1 == MPQ_FILE_DEFAULT_INTERNAL)
ha->dwFileFlags1 = GetDefaultSpecialFileFlags(cbListFile, ha->pHeader->wFormatVersion);
// Create the listfile in the MPQ
diff --git a/src/StormLib.h b/src/StormLib.h
index ca84cbc..f7512e5 100644
--- a/src/StormLib.h
+++ b/src/StormLib.h
@@ -220,6 +220,8 @@ extern "C" {
#define MPQ_FILE_COMPRESS_MASK 0x0000FF00 // Mask for a file being compressed
+#define MPQ_FILE_DEFAULT_INTERNAL 0xFFFFFFFF // Use default flags for internal files
+
#define MPQ_FILE_VALID_FLAGS (MPQ_FILE_IMPLODE | \
MPQ_FILE_COMPRESS | \
MPQ_FILE_ENCRYPTED | \
@@ -915,9 +917,9 @@ typedef struct _SFILE_CREATE_MPQ
void *pvUserData; // Reserved, must be NULL
DWORD cbUserData; // Reserved, must be 0
DWORD dwStreamFlags; // Stream flags for creating the MPQ
- DWORD dwFileFlags1; // File flags for (listfile). 0 = default
- DWORD dwFileFlags2; // File flags for (attributes). 0 = default
- DWORD dwFileFlags3; // File flags for (signature). 0 = default
+ DWORD dwFileFlags1; // File flags for (listfile). Use MPQ_FILE_DEFAULT_INTERNAL to set default flags
+ DWORD dwFileFlags2; // File flags for (attributes). Use MPQ_FILE_DEFAULT_INTERNAL to set default flags
+ DWORD dwFileFlags3; // File flags for (signature). Use MPQ_FILE_DEFAULT_INTERNAL to set default flags
DWORD dwAttrFlags; // Flags for the (attributes) file. If 0, no attributes will be created
DWORD dwSectorSize; // Sector size for compressed files
DWORD dwRawChunkSize; // Size of raw data chunk
diff --git a/test/StormTest.cpp b/test/StormTest.cpp
index 5dae52a..afc0a9f 100644
--- a/test/StormTest.cpp
+++ b/test/StormTest.cpp
@@ -1793,9 +1793,11 @@ static int CreateNewArchive_V2(TLogHelper * pLogger, const char * szPlainName, D
CreateInfo.cbSize = sizeof(SFILE_CREATE_MPQ);
CreateInfo.dwMpqVersion = (dwCreateFlags & MPQ_CREATE_ARCHIVE_VMASK) >> FLAGS_TO_FORMAT_SHIFT;
CreateInfo.dwStreamFlags = STREAM_PROVIDER_FLAT | BASE_PROVIDER_FILE;
- CreateInfo.dwFileFlags1 = (dwCreateFlags & MPQ_CREATE_LISTFILE) ? MPQ_FILE_EXISTS : 0;
- CreateInfo.dwFileFlags2 = (dwCreateFlags & MPQ_CREATE_ATTRIBUTES) ? MPQ_FILE_EXISTS : 0;
- CreateInfo.dwFileFlags3 = (dwCreateFlags & MPQ_CREATE_SIGNATURE) ? MPQ_FILE_EXISTS : 0;
+// CreateInfo.dwFileFlags1 = (dwCreateFlags & MPQ_CREATE_LISTFILE) ? MPQ_FILE_EXISTS : 0;
+// CreateInfo.dwFileFlags2 = (dwCreateFlags & MPQ_CREATE_ATTRIBUTES) ? MPQ_FILE_EXISTS : 0;
+ CreateInfo.dwFileFlags1 = (dwCreateFlags & MPQ_CREATE_LISTFILE) ? MPQ_FILE_DEFAULT_INTERNAL : 0;
+ CreateInfo.dwFileFlags2 = (dwCreateFlags & MPQ_CREATE_ATTRIBUTES) ? MPQ_FILE_DEFAULT_INTERNAL : 0;
+ CreateInfo.dwFileFlags3 = (dwCreateFlags & MPQ_CREATE_SIGNATURE) ? MPQ_FILE_DEFAULT_INTERNAL : 0;
CreateInfo.dwAttrFlags = (dwCreateFlags & MPQ_CREATE_ATTRIBUTES) ? (MPQ_ATTRIBUTE_CRC32 | MPQ_ATTRIBUTE_FILETIME | MPQ_ATTRIBUTE_MD5) : 0;
CreateInfo.dwSectorSize = (CreateInfo.dwMpqVersion >= MPQ_FORMAT_VERSION_3) ? 0x4000 : 0x1000;
CreateInfo.dwRawChunkSize = (CreateInfo.dwMpqVersion >= MPQ_FORMAT_VERSION_4) ? 0x4000 : 0;
@@ -4720,15 +4722,15 @@ int main(int argc, char * argv[])
// Create an empty archive v4
if(nError == ERROR_SUCCESS)
nError = TestCreateArchive_EmptyMpq("StormLibTest_EmptyMpq_v4.mpq", MPQ_CREATE_ARCHIVE_V4 | MPQ_CREATE_LISTFILE | MPQ_CREATE_ATTRIBUTES);
-
+*/
// Test creating of an archive the same way like MPQ Editor does
if(nError == ERROR_SUCCESS)
nError = TestCreateArchive_TestGaps("StormLibTest_GapsTest.mpq");
-*/
+/*
// Test creating of an archive with non standard file names
if(nError == ERROR_SUCCESS)
nError = TestCreateArchive_NonStdNames("StormLibTest_NonStdNames.mpq");
-/*
+
// Sign an existing non-signed archive
if(nError == ERROR_SUCCESS)
nError = TestOpenArchive_SignExisting("MPQ_1998_v1_StarDat.mpq");