From: ShadowFlare Date: Sun, 25 Oct 2009 07:09:30 +0000 (-0600) Subject: Add flag to SFileListFiles to allow flagging unknowns when listing all files. X-Git-Url: https://sfsrealm.hopto.org/projects/?a=commitdiff_plain;h=e32ff2fecf5ed03c2eb90343f9bc373852636f13;p=SFmpqapi.git Add flag to SFileListFiles to allow flagging unknowns when listing all files. --- diff --git a/SFmpqapi.bas b/SFmpqapi.bas index e6d38e6..0e42b71 100644 --- a/SFmpqapi.bas +++ b/SFmpqapi.bas @@ -199,6 +199,7 @@ Public Const SFILE_INFO_HASH_INDEX As Long = &HC 'Hash index of file in MPQ Public Const SFILE_LIST_MEMORY_LIST As Long = &H1 ' Specifies that lpFilelists is a file list from memory, rather than being a list of file lists Public Const SFILE_LIST_ONLY_KNOWN As Long = &H2 ' Only list files that the function finds a name for Public Const SFILE_LIST_ONLY_UNKNOWN As Long = &H4 ' Only list files that the function does not find a name for +Public Const SFILE_LIST_FLAG_UNKNOWN As Long = &H8 ' Use without SFILE_LIST_ONLY_KNOWN or SFILE_LIST_FLAG_UNKNOWN to list all files, but set dwFileExists to 3 if file's name is not found Public Const SFILE_TYPE_MPQ As Long = &H1 Public Const SFILE_TYPE_FILE As Long = &H2 diff --git a/SFmpqapi.cpp b/SFmpqapi.cpp index 0579c2c..86631f4 100644 --- a/SFmpqapi.cpp +++ b/SFmpqapi.cpp @@ -1526,7 +1526,10 @@ BOOL SFMPQAPI WINAPI SFileListFiles(MPQHANDLE hMPQ, LPCSTR lpFileLists, FILELIST lpListBuffer[i].dwCompressedSize = mpqOpenArc->lpBlockTable[dwBlockIndex].dwCompressedSize; lpListBuffer[i].dwFullSize = mpqOpenArc->lpBlockTable[dwBlockIndex].dwFullSize; lpListBuffer[i].dwFlags = mpqOpenArc->lpBlockTable[dwBlockIndex].dwFlags; - lpListBuffer[i].dwFileExists=0xFFFFFFFF; + if (dwFlags & SFILE_LIST_FLAG_UNKNOWN) + lpListBuffer[i].dwFileExists = 1; + else + lpListBuffer[i].dwFileExists=0xFFFFFFFF; SetFilePointer(mpqOpenArc->hFile,mpqOpenArc->dwMPQStart+mpqOpenArc->lpBlockTable[dwBlockIndex].dwFileOffset+0x40,0,FILE_BEGIN); ReadFile(mpqOpenArc->hFile,lpListBuffer[i].szFileName,260,&tsz,0); @@ -1537,6 +1540,10 @@ BOOL SFMPQAPI WINAPI SFileListFiles(MPQHANDLE hMPQ, LPCSTR lpFileLists, FILELIST } else { sprintf(lpListBuffer[i].szFileName,UNKNOWN_OUT,i); + if (dwFlags & SFILE_LIST_FLAG_UNKNOWN) { + lpListBuffer[i].dwFileExists |= 2; + } + if (dwFlags&SFILE_LIST_ONLY_KNOWN) { lpListBuffer[i].dwFileExists = 0; } @@ -1690,7 +1697,10 @@ BOOL SFMPQAPI WINAPI SFileListFiles(MPQHANDLE hMPQ, LPCSTR lpFileLists, FILELIST lpListBuffer[i].dwCompressedSize = mpqOpenArc->lpBlockTable[dwBlockIndex].dwCompressedSize; lpListBuffer[i].dwFullSize = mpqOpenArc->lpBlockTable[dwBlockIndex].dwFullSize; lpListBuffer[i].dwFlags = mpqOpenArc->lpBlockTable[dwBlockIndex].dwFlags; - lpListBuffer[i].dwFileExists=0xFFFFFFFF; + if (dwFlags & SFILE_LIST_FLAG_UNKNOWN) + lpListBuffer[i].dwFileExists = 1; + else + lpListBuffer[i].dwFileExists=0xFFFFFFFF; for (j=0;jlpHashTable[i].dwNameHashA==lpdwNameHashA[j] && mpqOpenArc->lpHashTable[i].dwNameHashB==lpdwNameHashB[j]) { strncpy(lpListBuffer[i].szFileName,lpNames[j],260); @@ -1701,6 +1711,10 @@ BOOL SFMPQAPI WINAPI SFileListFiles(MPQHANDLE hMPQ, LPCSTR lpFileLists, FILELIST } if (j+1==dwTotalLines) { sprintf(lpListBuffer[i].szFileName,UNKNOWN_OUT,i); + if (dwFlags & SFILE_LIST_FLAG_UNKNOWN) { + lpListBuffer[i].dwFileExists |= 2; + } + if (dwFlags&SFILE_LIST_ONLY_KNOWN) { lpListBuffer[i].dwFileExists = 0; } diff --git a/SFmpqapi.h b/SFmpqapi.h index 7fe313d..5626028 100644 --- a/SFmpqapi.h +++ b/SFmpqapi.h @@ -281,6 +281,7 @@ long SFMPQAPI __inline SFMpqCompareVersion(); #define SFILE_LIST_MEMORY_LIST 0x01 // Specifies that lpFilelists is a file list from memory, rather than being a list of file lists #define SFILE_LIST_ONLY_KNOWN 0x02 // Only list files that the function finds a name for #define SFILE_LIST_ONLY_UNKNOWN 0x04 // Only list files that the function does not find a name for +#define SFILE_LIST_FLAG_UNKNOWN 0x08 // Use without SFILE_LIST_ONLY_KNOWN or SFILE_LIST_FLAG_UNKNOWN to list all files, but set dwFileExists to 3 if file's name is not found // SFileOpenArchive flags #define SFILE_OPEN_HARD_DISK_FILE 0x0000 //Open archive without regard to the drive type it resides on diff --git a/SFmpqapi_no-lib.h b/SFmpqapi_no-lib.h index 72bb672..06e04fb 100644 --- a/SFmpqapi_no-lib.h +++ b/SFmpqapi_no-lib.h @@ -265,6 +265,7 @@ long SFMpqCompareVersion(); #define SFILE_LIST_MEMORY_LIST 0x01 // Specifies that lpFilelists is a file list from memory, rather than being a list of file lists #define SFILE_LIST_ONLY_KNOWN 0x02 // Only list files that the function finds a name for #define SFILE_LIST_ONLY_UNKNOWN 0x04 // Only list files that the function does not find a name for +#define SFILE_LIST_FLAG_UNKNOWN 0x08 // Use without SFILE_LIST_ONLY_KNOWN or SFILE_LIST_FLAG_UNKNOWN to list all files, but set dwFileExists to 3 if file's name is not found // SFileOpenArchive flags #define SFILE_OPEN_HARD_DISK_FILE 0x0000 //Open archive without regard to the drive type it resides on