[Common] CFile::Write(): Use standard memory size input type.

This commit is contained in:
unknown 2015-11-06 13:02:45 -05:00
parent 43f175ce70
commit a3cac34c74
3 changed files with 10 additions and 6 deletions

View File

@ -140,15 +140,19 @@ bool CFile::Flush()
return ::FlushFileBuffers(m_hFile) != 0;
}
bool CFile::Write(const void* lpBuf, uint32_t nCount)
bool CFile::Write(const void* lpBuf, size_t nCount)
{
if (nCount == 0)
{
return true; // avoid Win32 "null-write" option
}
if (nCount > ULONG_MAX)
{
nCount = ULONG_MAX; /* Or should we loop WriteFile() every 2 GB? */
}
ULONG nWritten = 0;
if (!::WriteFile(m_hFile, lpBuf, nCount, &nWritten, NULL))
DWORD nWritten = 0;
if (!::WriteFile(m_hFile, lpBuf, (DWORD)nCount, &nWritten, NULL))
{
return false;
}

View File

@ -41,7 +41,7 @@ public:
virtual uint32_t GetLength() const = 0;
virtual uint32_t Read(void* lpBuf, uint32_t nCount) = 0;
virtual bool Write(const void* lpBuf, uint32_t nCount) = 0;
virtual bool Write(const void* lpBuf, size_t nCount) = 0;
virtual bool Flush() = 0;
virtual bool Close() = 0;
@ -79,7 +79,7 @@ public:
virtual uint32_t GetLength() const;
virtual uint32_t Read(void* lpBuf, uint32_t nCount);
virtual bool Write(const void* lpBuf, uint32_t nCount);
virtual bool Write(const void* lpBuf, size_t nCount);
virtual bool Flush();
virtual bool Close();

View File

@ -120,7 +120,7 @@ void CLog::LogArgs(const char * Message, va_list & args )
void CLog::Log( const char * Message )
{
if (!m_hLogFile.IsOpen()) { return; }
m_hLogFile.Write(Message,(uint32_t)strlen(Message)*sizeof(TCHAR));
m_hLogFile.Write(Message, strlen(Message)*sizeof(TCHAR));
if (m_FlushOnWrite)
{
m_hLogFile.Flush();