[Common] MaxFileSize: Use size_t for memory sizes.

This commit is contained in:
unknown 2015-11-06 12:18:44 -05:00
parent 43f175ce70
commit dd9bb892cb
3 changed files with 12 additions and 15 deletions

View File

@ -15,8 +15,8 @@ class CLog
bool m_FlushOnWrite;
stdstr m_FileName;
bool m_TruncateFileLog;
uint32_t m_MaxFileSize;
uint32_t m_FileChangeSize;
size_t m_MaxFileSize;
size_t m_FileChangeSize;
public:
CLog ( void );
@ -29,10 +29,10 @@ public:
bool Empty ( void );
void Close ( void );
inline void SetMaxFileSize ( uint32_t Size )
{
m_MaxFileSize = Size;
m_FileChangeSize = (uint32_t)(Size * 0.1);
inline void SetMaxFileSize(size_t Size)
{
m_MaxFileSize = Size;
m_FileChangeSize = (size_t)(Size * 0.1);
}
inline void SetTruncateFile( bool Truncate ) { m_TruncateFileLog = Truncate; }
inline void SetFlush ( bool Always ) { m_FlushOnWrite = Always; }

View File

@ -191,7 +191,7 @@ m_FlushFile(FlushFile)
m_hLogFile.Open(FileName, Log_Append);
}
CTraceFileLog::CTraceFileLog(LPCTSTR FileName, bool FlushFile, LOG_OPEN_MODE eMode, uint32_t dwMaxFileSize) :
CTraceFileLog::CTraceFileLog(LPCTSTR FileName, bool FlushFile, LOG_OPEN_MODE eMode, size_t dwMaxFileSize) :
m_FlushFile(FlushFile)
{
enum { MB = 1024 * 1024 };
@ -199,14 +199,11 @@ m_FlushFile(FlushFile)
m_hLogFile.SetFlush(false);
m_hLogFile.SetTruncateFile(true);
if (dwMaxFileSize < 2048 && dwMaxFileSize > 2)
{
m_hLogFile.SetMaxFileSize(dwMaxFileSize * MB);
}
else
{
m_hLogFile.SetMaxFileSize(5 * MB);
if (dwMaxFileSize < 3 || dwMaxFileSize > 2047)
{ /* Clamp file size to 5 MB if it exceeds 2047 or falls short of 3. */
dwMaxFileSize = 5;
}
m_hLogFile.SetMaxFileSize(dwMaxFileSize * MB);
m_hLogFile.Open(FileName, eMode);
}

View File

@ -26,7 +26,7 @@ class CTraceFileLog : public CTraceModule
public:
CTraceFileLog (const char * FileName, bool FlushFile = true);
CTraceFileLog (const char * FileName, bool FlushFile, LOG_OPEN_MODE eMode, uint32_t dwMaxFileSize = 5);
CTraceFileLog(const char * FileName, bool FlushFile, LOG_OPEN_MODE eMode, size_t dwMaxFileSize = 5);
virtual ~CTraceFileLog ();
void Write ( const char * Message, bool EndOfLine );