+ More paratemer checking to make nitpickers happy

This commit is contained in:
unknown
2015-01-18 17:34:34 +01:00
parent e9842c38cf
commit 23ffb9d452
6 changed files with 97 additions and 83 deletions

View File

@@ -34,26 +34,23 @@ bool WINAPI SFileExtractFile(HANDLE hMpq, const char * szToExtract, const TCHAR
}
// Copy the file's content
if(nError == ERROR_SUCCESS)
while(nError == ERROR_SUCCESS)
{
char szBuffer[0x1000];
DWORD dwTransferred;
DWORD dwTransferred = 0;
for(;;)
{
// dwTransferred is only set to nonzero if something has been read.
// nError can be ERROR_SUCCESS or ERROR_HANDLE_EOF
if(!SFileReadFile(hMpqFile, szBuffer, sizeof(szBuffer), &dwTransferred, NULL))
nError = GetLastError();
if(nError == ERROR_HANDLE_EOF)
nError = ERROR_SUCCESS;
if(dwTransferred == 0)
break;
// dwTransferred is only set to nonzero if something has been read.
// nError can be ERROR_SUCCESS or ERROR_HANDLE_EOF
if(!SFileReadFile(hMpqFile, szBuffer, sizeof(szBuffer), &dwTransferred, NULL))
nError = GetLastError();
if(nError == ERROR_HANDLE_EOF)
nError = ERROR_SUCCESS;
if(dwTransferred == 0)
break;
// If something has been actually read, write it
if(!FileStream_Write(pLocalFile, NULL, szBuffer, dwTransferred))
nError = GetLastError();
}
// If something has been actually read, write it
if(!FileStream_Write(pLocalFile, NULL, szBuffer, dwTransferred))
nError = GetLastError();
}
// Close the files