diff --git a/Source/Common/File Class.cpp b/Source/Common/File Class.cpp index 39166f792..48acd893a 100644 --- a/Source/Common/File Class.cpp +++ b/Source/Common/File Class.cpp @@ -165,19 +165,23 @@ bool CFile::Write(const void* lpBuf, size_t nCount) return true; } -uint32_t CFile::Read(void* lpBuf, uint32_t nCount) +size_t CFile::Read(void* lpBuf, size_t nCount) { if (nCount == 0) { return 0; // avoid Win32 "null-read" } + if (nCount > ULONG_MAX) + { + nCount = ULONG_MAX; /* Or should we loop ReadFile() every 2 GB? */ + } DWORD dwRead = 0; - if (!::ReadFile(m_hFile, lpBuf, nCount, &dwRead, NULL)) + if (!::ReadFile(m_hFile, lpBuf, (DWORD)nCount, &dwRead, NULL)) { return 0; } - return (uint32_t)dwRead; + return (dwRead); } long CFile::Seek(long lOff, SeekPosition nFrom) diff --git a/Source/Common/File Class.h b/Source/Common/File Class.h index b47709da0..c61730450 100644 --- a/Source/Common/File Class.h +++ b/Source/Common/File Class.h @@ -40,7 +40,7 @@ public: virtual bool SetLength(uint32_t dwNewLen) = 0; virtual uint32_t GetLength() const = 0; - virtual uint32_t Read(void* lpBuf, uint32_t nCount) = 0; + virtual size_t Read(void* lpBuf, size_t nCount) = 0; virtual bool Write(const void* lpBuf, size_t nCount) = 0; virtual bool Flush() = 0; @@ -78,7 +78,7 @@ public: virtual bool SetLength(uint32_t dwNewLen); virtual uint32_t GetLength() const; - virtual uint32_t Read(void* lpBuf, uint32_t nCount); + virtual size_t Read(void* lpBuf, size_t nCount); virtual bool Write(const void* lpBuf, size_t nCount); virtual bool Flush(); diff --git a/Source/Common/Log Class.cpp b/Source/Common/Log Class.cpp index 4eebfc35a..a0a9560fd 100644 --- a/Source/Common/Log Class.cpp +++ b/Source/Common/Log Class.cpp @@ -145,13 +145,13 @@ void CLog::Log( const char * Message ) m_hLogFile.Seek((end - m_MaxFileSize) + m_FileChangeSize,CFile::begin); // Find next end of line - uint32_t NextEnter = 0, dwRead = 0; + size_t NextEnter = 0, dwRead = 0; do { BYTE Data[300]; - uint32_t dwRead; + size_t dwRead; - dwRead = m_hLogFile.Read(Data,sizeof(Data)); + dwRead = m_hLogFile.Read(Data, sizeof(Data)); if (dwRead == 0) { break; @@ -170,8 +170,9 @@ void CLog::Log( const char * Message ) } while(dwRead != 0); // copy content of log to the new file - uint32_t ReadPos = (end - m_MaxFileSize) + m_FileChangeSize + NextEnter; - uint32_t SizeToRead, WritePos = 0; + size_t ReadPos = (end - m_MaxFileSize) + m_FileChangeSize + NextEnter; + uint32_t WritePos = 0; + size_t SizeToRead; do { enum { fIS_MvSize = 0x5000 }; @@ -182,8 +183,8 @@ void CLog::Log( const char * Message ) m_hLogFile.Seek(ReadPos,CFile::begin); - uint32_t dwRead; - dwRead = m_hLogFile.Read(Data,SizeToRead); + size_t dwRead; + dwRead = m_hLogFile.Read(Data, SizeToRead); m_hLogFile.Seek(WritePos,CFile::begin);