mirror of
https://github.com/ladislav-zezula/StormLib.git
synced 2026-02-04 21:36:24 +01:00
nError -> dwErrCode
This commit is contained in:
@@ -291,7 +291,7 @@ static bool DoMPQSearch_FileEntry(
|
||||
return false;
|
||||
}
|
||||
|
||||
static int DoMPQSearch_HashTable(TMPQSearch * hs, SFILE_FIND_DATA * lpFindFileData, TMPQArchive * ha)
|
||||
static DWORD DoMPQSearch_HashTable(TMPQSearch * hs, SFILE_FIND_DATA * lpFindFileData, TMPQArchive * ha)
|
||||
{
|
||||
TMPQHash * pHashTableEnd = ha->pHashTable + ha->pHeader->dwHashTableSize;
|
||||
TMPQHash * pHash;
|
||||
@@ -315,7 +315,7 @@ static int DoMPQSearch_HashTable(TMPQSearch * hs, SFILE_FIND_DATA * lpFindFileDa
|
||||
return ERROR_NO_MORE_FILES;
|
||||
}
|
||||
|
||||
static int DoMPQSearch_FileTable(TMPQSearch * hs, SFILE_FIND_DATA * lpFindFileData, TMPQArchive * ha)
|
||||
static DWORD DoMPQSearch_FileTable(TMPQSearch * hs, SFILE_FIND_DATA * lpFindFileData, TMPQArchive * ha)
|
||||
{
|
||||
TFileEntry * pFileTableEnd = ha->pFileTable + ha->dwFileTableSize;
|
||||
TFileEntry * pFileEntry;
|
||||
@@ -336,10 +336,10 @@ static int DoMPQSearch_FileTable(TMPQSearch * hs, SFILE_FIND_DATA * lpFindFileDa
|
||||
}
|
||||
|
||||
// Performs one MPQ search
|
||||
static int DoMPQSearch(TMPQSearch * hs, SFILE_FIND_DATA * lpFindFileData)
|
||||
static DWORD DoMPQSearch(TMPQSearch * hs, SFILE_FIND_DATA * lpFindFileData)
|
||||
{
|
||||
TMPQArchive * ha = hs->ha;
|
||||
int nError;
|
||||
DWORD dwErrCode;
|
||||
|
||||
// Start searching with base MPQ
|
||||
while(ha != NULL)
|
||||
@@ -348,10 +348,10 @@ static int DoMPQSearch(TMPQSearch * hs, SFILE_FIND_DATA * lpFindFileData)
|
||||
// in order to catch hash table index and file locale.
|
||||
// Note: If multiple hash table entries, point to the same block entry,
|
||||
// we need, to report them all
|
||||
nError = (ha->pHashTable != NULL) ? DoMPQSearch_HashTable(hs, lpFindFileData, ha)
|
||||
: DoMPQSearch_FileTable(hs, lpFindFileData, ha);
|
||||
if(nError == ERROR_SUCCESS)
|
||||
return nError;
|
||||
dwErrCode = (ha->pHashTable != NULL) ? DoMPQSearch_HashTable(hs, lpFindFileData, ha)
|
||||
: DoMPQSearch_FileTable(hs, lpFindFileData, ha);
|
||||
if(dwErrCode == ERROR_SUCCESS)
|
||||
return dwErrCode;
|
||||
|
||||
// If there is no more patches in the chain, stop it.
|
||||
// This also keeps hs->ha non-NULL, which is required
|
||||
@@ -387,30 +387,30 @@ HANDLE WINAPI SFileFindFirstFile(HANDLE hMpq, const char * szMask, SFILE_FIND_DA
|
||||
TMPQArchive * ha = (TMPQArchive *)hMpq;
|
||||
TMPQSearch * hs = NULL;
|
||||
size_t nSize = 0;
|
||||
int nError = ERROR_SUCCESS;
|
||||
DWORD dwErrCode = ERROR_SUCCESS;
|
||||
|
||||
// Check for the valid parameters
|
||||
if(!IsValidMpqHandle(hMpq))
|
||||
nError = ERROR_INVALID_HANDLE;
|
||||
dwErrCode = ERROR_INVALID_HANDLE;
|
||||
if(szMask == NULL || lpFindFileData == NULL)
|
||||
nError = ERROR_INVALID_PARAMETER;
|
||||
dwErrCode = ERROR_INVALID_PARAMETER;
|
||||
|
||||
// Include the listfile into the MPQ's internal listfile
|
||||
// Note that if the listfile name is NULL, do nothing because the
|
||||
// internal listfile is always included.
|
||||
if(nError == ERROR_SUCCESS && szListFile != NULL && *szListFile != 0)
|
||||
nError = SFileAddListFile((HANDLE)ha, szListFile);
|
||||
if(dwErrCode == ERROR_SUCCESS && szListFile != NULL && *szListFile != 0)
|
||||
dwErrCode = SFileAddListFile((HANDLE)ha, szListFile);
|
||||
|
||||
// Allocate the structure for MPQ search
|
||||
if(nError == ERROR_SUCCESS)
|
||||
if(dwErrCode == ERROR_SUCCESS)
|
||||
{
|
||||
nSize = sizeof(TMPQSearch) + strlen(szMask) + 1;
|
||||
if((hs = (TMPQSearch *)STORM_ALLOC(char, nSize)) == NULL)
|
||||
nError = ERROR_NOT_ENOUGH_MEMORY;
|
||||
dwErrCode = ERROR_NOT_ENOUGH_MEMORY;
|
||||
}
|
||||
|
||||
// Perform the first search
|
||||
if(nError == ERROR_SUCCESS)
|
||||
if(dwErrCode == ERROR_SUCCESS)
|
||||
{
|
||||
memset(hs, 0, sizeof(TMPQSearch));
|
||||
strcpy(hs->szSearchMask, szMask);
|
||||
@@ -427,21 +427,21 @@ HANDLE WINAPI SFileFindFirstFile(HANDLE hMpq, const char * szMask, SFILE_FIND_DA
|
||||
if(hs->pSearchTable != NULL)
|
||||
memset(hs->pSearchTable, 0, hs->dwSearchTableItems * sizeof(TFileEntry *));
|
||||
else
|
||||
nError = ERROR_NOT_ENOUGH_MEMORY;
|
||||
dwErrCode = ERROR_NOT_ENOUGH_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
// Perform first item searching
|
||||
if(nError == ERROR_SUCCESS)
|
||||
if(dwErrCode == ERROR_SUCCESS)
|
||||
{
|
||||
nError = DoMPQSearch(hs, lpFindFileData);
|
||||
dwErrCode = DoMPQSearch(hs, lpFindFileData);
|
||||
}
|
||||
|
||||
// Cleanup
|
||||
if(nError != ERROR_SUCCESS)
|
||||
if(dwErrCode != ERROR_SUCCESS)
|
||||
{
|
||||
FreeMPQSearch(hs);
|
||||
SetLastError(nError);
|
||||
SetLastError(dwErrCode);
|
||||
}
|
||||
|
||||
// Return the result value
|
||||
@@ -451,20 +451,20 @@ HANDLE WINAPI SFileFindFirstFile(HANDLE hMpq, const char * szMask, SFILE_FIND_DA
|
||||
bool WINAPI SFileFindNextFile(HANDLE hFind, SFILE_FIND_DATA * lpFindFileData)
|
||||
{
|
||||
TMPQSearch * hs = IsValidSearchHandle(hFind);
|
||||
int nError = ERROR_SUCCESS;
|
||||
DWORD dwErrCode = ERROR_SUCCESS;
|
||||
|
||||
// Check the parameters
|
||||
if(hs == NULL)
|
||||
nError = ERROR_INVALID_HANDLE;
|
||||
dwErrCode = ERROR_INVALID_HANDLE;
|
||||
if(lpFindFileData == NULL)
|
||||
nError = ERROR_INVALID_PARAMETER;
|
||||
dwErrCode = ERROR_INVALID_PARAMETER;
|
||||
|
||||
if(nError == ERROR_SUCCESS)
|
||||
nError = DoMPQSearch(hs, lpFindFileData);
|
||||
if(dwErrCode == ERROR_SUCCESS)
|
||||
dwErrCode = DoMPQSearch(hs, lpFindFileData);
|
||||
|
||||
if(nError != ERROR_SUCCESS)
|
||||
SetLastError(nError);
|
||||
return (nError == ERROR_SUCCESS);
|
||||
if(dwErrCode != ERROR_SUCCESS)
|
||||
SetLastError(dwErrCode);
|
||||
return (dwErrCode == ERROR_SUCCESS);
|
||||
}
|
||||
|
||||
bool WINAPI SFileFindClose(HANDLE hFind)
|
||||
|
||||
Reference in New Issue
Block a user