Browse Source

Storm: Fix reading local files

See https://github.com/ladislav-zezula/StormLib/issues/203
pull/1310/head
Gleb Mazovetskiy 5 years ago committed by Anders Jenbo
parent
commit
e2158a2102
  1. 10
      3rdParty/StormLib/src/SFileReadFile.cpp

10
3rdParty/StormLib/src/SFileReadFile.cpp vendored

@ -711,7 +711,12 @@ bool STORMAPI SFileReadFile(HANDLE hFile, void * pvBuffer, DWORD dwToRead, LPDWO
// If the file is local file, read the data directly from the stream // If the file is local file, read the data directly from the stream
if(hf->pStream != NULL) if(hf->pStream != NULL)
{ {
nError = ReadMpqFileLocalFile(hf, pvBuffer, hf->dwFilePos, dwToRead, &dwBytesRead); ULONGLONG pos;
if (!FileStream_GetPos(hf->pStream, &pos)) {
SetLastError(ERROR_CAN_NOT_COMPLETE);
return false;
}
nError = ReadMpqFileLocalFile(hf, pvBuffer, pos, dwToRead, &dwBytesRead);
} }
#ifdef FULL #ifdef FULL
// If the file is a patch file, we have to read it special way // If the file is a patch file, we have to read it special way
@ -739,7 +744,8 @@ bool STORMAPI SFileReadFile(HANDLE hFile, void * pvBuffer, DWORD dwToRead, LPDWO
} }
// Increment the file position // Increment the file position
hf->dwFilePos += dwBytesRead; if(hf->pStream == NULL)
hf->dwFilePos += dwBytesRead;
// Give the caller the number of bytes read // Give the caller the number of bytes read
if(pdwRead != NULL) if(pdwRead != NULL)

Loading…
Cancel
Save