diff options
author | Ladislav Zezula <zezula@volny.cz> | 2025-07-03 09:27:16 +0200 |
---|---|---|
committer | Ladislav Zezula <zezula@volny.cz> | 2025-07-03 09:27:16 +0200 |
commit | 486a7dd29f3bdf884d4be5588d9171daa5da1bae (patch) | |
tree | 95d9d099a84a3587412eecffd2485da99820916b /test/StormTest.cpp | |
parent | b41cda40f9c3fbdb802cf63e739425cd805eecaa (diff) |
Replaced GetLastError with SErrGetLastError
Diffstat (limited to 'test/StormTest.cpp')
-rwxr-xr-x | test/StormTest.cpp | 54 |
1 files changed, 28 insertions, 26 deletions
diff --git a/test/StormTest.cpp b/test/StormTest.cpp index c5b5121..285f381 100755 --- a/test/StormTest.cpp +++ b/test/StormTest.cpp @@ -614,7 +614,7 @@ static DWORD CalculateFileHash(TLogHelper * pLogger, LPCTSTR szFullPath, LPTSTR cbBytesToRead = ((FileSize - ByteOffset) > cbFileBlock) ? cbFileBlock : (DWORD)(FileSize - ByteOffset);
if(!FileStream_Read(pStream, &ByteOffset, pbFileBlock, cbBytesToRead))
{
- dwErrCode = GetLastError();
+ dwErrCode = SErrGetLastError();
break;
}
@@ -858,7 +858,7 @@ static DWORD ForEachFile_VerifyFileHash(LPCTSTR szFullPath, void * lpContext) StringCopy(szHashTextA, _countof(szHashTextA), szHashText);
if(_strnicmp(szHashTextA, GetFileText(pFileData), (SHA256_DIGEST_SIZE * 2)))
{
- SetLastError(dwErrCode = ERROR_FILE_CORRUPT);
+ SErrSetLastError(dwErrCode = ERROR_FILE_CORRUPT);
pLogger->PrintError(_T("File hash check failed: %s"), szFullPath);
}
}
@@ -1040,7 +1040,7 @@ static DWORD GetFilePatchCount(TLogHelper * pLogger, HANDLE hMpq, LPCSTR szFileN }
else
{
- if(GetLastError() != ERROR_FILE_DELETED)
+ if(SErrGetLastError() != ERROR_FILE_DELETED)
{
pLogger->PrintError("Open failed: %s", szFileName);
}
@@ -1163,7 +1163,7 @@ static DWORD WriteMpqUserDataHeader( UserData.dwHeaderOffs = (dwByteCount + sizeof(TMPQUserData));
UserData.cbUserDataHeader = dwByteCount / 2;
if(!FileStream_Write(pStream, &ByteOffset, &UserData, sizeof(TMPQUserData)))
- dwErrCode = GetLastError();
+ dwErrCode = SErrGetLastError();
return dwErrCode;
}
@@ -1197,7 +1197,7 @@ static DWORD WriteFileData( // Write the data
if(!FileStream_Write(pStream, &ByteOffset, pbDataBuffer, cbToWrite))
{
- dwErrCode = GetLastError();
+ dwErrCode = SErrGetLastError();
break;
}
@@ -1235,14 +1235,14 @@ static DWORD CopyFileData( BytesToRead = ((EndOffset - ByteOffset) > BlockLength) ? BlockLength : (DWORD)(EndOffset - ByteOffset);
if(!FileStream_Read(pStream1, &ByteOffset, pbCopyBuffer, BytesToRead))
{
- dwErrCode = GetLastError();
+ dwErrCode = SErrGetLastError();
break;
}
// Write to the destination file
if(!FileStream_Write(pStream2, NULL, pbCopyBuffer, BytesToRead))
{
- dwErrCode = GetLastError();
+ dwErrCode = SErrGetLastError();
break;
}
@@ -1519,7 +1519,7 @@ static DWORD LoadMpqFile(TLogHelper & Logger, HANDLE hMpq, LPCSTR szFileName, LC }
else
{
- if((dwSearchFlags & SEARCH_FLAG_IGNORE_ERRORS) == 0 && GetLastError() != ERROR_FILE_DELETED)
+ if((dwSearchFlags & SEARCH_FLAG_IGNORE_ERRORS) == 0 && SErrGetLastError() != ERROR_FILE_DELETED)
{
dwErrCode = Logger.PrintError("Open failed: %s", szFileName);
}
@@ -1663,7 +1663,7 @@ static DWORD SearchArchive( hFind = SFileFindFirstFile(hMpq, "*", &sf, szListFile);
if(hFind == NULL)
{
- dwErrCode = GetLastError();
+ dwErrCode = SErrGetLastError();
dwErrCode = (dwErrCode == ERROR_NO_MORE_FILES) ? ERROR_SUCCESS : dwErrCode;
return dwErrCode;
}
@@ -1866,11 +1866,11 @@ static DWORD OpenExistingArchive(TLogHelper * pLogger, LPCTSTR szFullPath, DWORD pLogger->PrintProgress(_T("Opening archive %s ..."), GetShortPlainName(szFullPath));
if(!SFileOpenArchive(szFullPath, 0, dwOpenFlags, &hMpq))
{
- switch(dwErrCode = GetLastError())
+ switch(dwErrCode = SErrGetLastError())
{
// case ERROR_BAD_FORMAT: // If the error is ERROR_BAD_FORMAT, try to open with MPQ_OPEN_FORCE_MPQ_V1
// bReopenResult = SFileOpenArchive(szMpqName, 0, dwFlags | MPQ_OPEN_FORCE_MPQ_V1, &hMpq);
-// dwErrCode = (bReopenResult == false) ? GetLastError() : ERROR_SUCCESS;
+// dwErrCode = (bReopenResult == false) ? SErrGetLastError() : ERROR_SUCCESS;
// break;
case ERROR_AVI_FILE: // Ignore the error if it's an AVI file or if the file is incomplete
@@ -1960,7 +1960,7 @@ static DWORD AddFileToMpq( }
else
{
- dwErrCode = GetLastError();
+ dwErrCode = SErrGetLastError();
}
// Check the expected error code
@@ -2006,7 +2006,7 @@ static DWORD AddLocalFileToMpq( {
if(bMustSucceed)
return pLogger->PrintError("Failed to add the file %s", szArchivedName);
- return GetLastError();
+ return SErrGetLastError();
}
// Verify the file unless it was lossy compression
@@ -2033,7 +2033,7 @@ static DWORD RemoveMpqFile(TLogHelper * pLogger, HANDLE hMpq, LPCSTR szFileName, // Perform the deletion
if(!SFileRemoveFile(hMpq, szFileName, 0))
- dwErrCode = GetLastError();
+ dwErrCode = SErrGetLastError();
if(dwErrCode != dwExpectedError)
return pLogger->PrintError("Unexpected result from SFileRemoveFile(%s)", szFileName);
@@ -2059,7 +2059,7 @@ static void TestGetFileInfo( // Call the get file info
bResult = SFileGetFileInfo(hMpqOrFile, InfoClass, pvFileInfo, cbFileInfo, pcbLengthNeeded);
if(!bResult)
- dwErrCode = GetLastError();
+ dwErrCode = SErrGetLastError();
// Check the expected results
if(bResult != bExpectedResult)
@@ -2758,7 +2758,7 @@ static DWORD TestOpenArchive( // Reset error code, if the failure is expected
if((dwErrCode != ERROR_SUCCESS || hMpq == NULL) && (dwFlags & TFLG_WILL_FAIL))
- SetLastError(dwErrCode = ERROR_SUCCESS);
+ SErrSetLastError(dwErrCode = ERROR_SUCCESS);
// Cleanup and exit
if(hMpq != NULL)
@@ -3092,7 +3092,7 @@ static DWORD TestCreateArchive_TestGaps(LPCTSTR szPlainName) SFileCloseFile(hFile);
}
else
- dwErrCode = GetLastError();
+ dwErrCode = SErrGetLastError();
}
}
@@ -3111,7 +3111,7 @@ static DWORD TestCreateArchive_TestGaps(LPCTSTR szPlainName) SFileCloseFile(hFile);
}
else
- dwErrCode = GetLastError();
+ dwErrCode = SErrGetLastError();
}
// Now check the positions
@@ -3869,23 +3869,25 @@ static DWORD TestUtf8Conversions(const BYTE * szTestString, const TCHAR * szList static void Test_PlayingSpace()
{
-/*
HANDLE hMpq;
HANDLE hFile;
+ LPBYTE pbData;
+ DWORD dwFileSize = 529298;
+ DWORD dwBytesRead = 0;
- if(SFileOpenArchive(_T("e:\\Ladik\\Incoming\\WoW-1.11.2.5464-to-1.12.0.5595-enUS-patch.exe"), 0, 0, &hMpq))
+ if(SFileOpenArchive(_T("c:\\War3.mpq"), 0, 0, &hMpq))
{
- if(SFileOpenFileEx(hMpq, "AccountLogin.xml", 0, &hFile))
+ if(SFileOpenFileEx(hMpq, "(listfile)", 0, &hFile))
{
- DWORD dwBytesRead = 0;
- BYTE Buffer[1024];
-
- SFileReadFile(hFile, Buffer, sizeof(Buffer), &dwBytesRead, NULL);
+ if((pbData = STORM_ALLOC(BYTE, dwFileSize)) != NULL)
+ {
+ SFileReadFile(hFile, pbData, dwFileSize, &dwBytesRead, NULL);
+ STORM_FREE(pbData);
+ }
SFileCloseFile(hFile);
}
SFileCloseArchive(hMpq);
}
-*/
}
//-----------------------------------------------------------------------------
|