[Common] MaxFileSize: Use size_t for memory sizes.
This commit is contained in:
parent
43f175ce70
commit
dd9bb892cb
|
@ -15,8 +15,8 @@ class CLog
|
||||||
bool m_FlushOnWrite;
|
bool m_FlushOnWrite;
|
||||||
stdstr m_FileName;
|
stdstr m_FileName;
|
||||||
bool m_TruncateFileLog;
|
bool m_TruncateFileLog;
|
||||||
uint32_t m_MaxFileSize;
|
size_t m_MaxFileSize;
|
||||||
uint32_t m_FileChangeSize;
|
size_t m_FileChangeSize;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CLog ( void );
|
CLog ( void );
|
||||||
|
@ -29,10 +29,10 @@ public:
|
||||||
bool Empty ( void );
|
bool Empty ( void );
|
||||||
void Close ( void );
|
void Close ( void );
|
||||||
|
|
||||||
inline void SetMaxFileSize ( uint32_t Size )
|
inline void SetMaxFileSize(size_t Size)
|
||||||
{
|
{
|
||||||
m_MaxFileSize = Size;
|
m_MaxFileSize = Size;
|
||||||
m_FileChangeSize = (uint32_t)(Size * 0.1);
|
m_FileChangeSize = (size_t)(Size * 0.1);
|
||||||
}
|
}
|
||||||
inline void SetTruncateFile( bool Truncate ) { m_TruncateFileLog = Truncate; }
|
inline void SetTruncateFile( bool Truncate ) { m_TruncateFileLog = Truncate; }
|
||||||
inline void SetFlush ( bool Always ) { m_FlushOnWrite = Always; }
|
inline void SetFlush ( bool Always ) { m_FlushOnWrite = Always; }
|
||||||
|
|
|
@ -191,7 +191,7 @@ m_FlushFile(FlushFile)
|
||||||
m_hLogFile.Open(FileName, Log_Append);
|
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)
|
m_FlushFile(FlushFile)
|
||||||
{
|
{
|
||||||
enum { MB = 1024 * 1024 };
|
enum { MB = 1024 * 1024 };
|
||||||
|
@ -199,14 +199,11 @@ m_FlushFile(FlushFile)
|
||||||
m_hLogFile.SetFlush(false);
|
m_hLogFile.SetFlush(false);
|
||||||
m_hLogFile.SetTruncateFile(true);
|
m_hLogFile.SetTruncateFile(true);
|
||||||
|
|
||||||
if (dwMaxFileSize < 2048 && dwMaxFileSize > 2)
|
if (dwMaxFileSize < 3 || dwMaxFileSize > 2047)
|
||||||
{
|
{ /* Clamp file size to 5 MB if it exceeds 2047 or falls short of 3. */
|
||||||
m_hLogFile.SetMaxFileSize(dwMaxFileSize * MB);
|
dwMaxFileSize = 5;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_hLogFile.SetMaxFileSize(5 * MB);
|
|
||||||
}
|
}
|
||||||
|
m_hLogFile.SetMaxFileSize(dwMaxFileSize * MB);
|
||||||
|
|
||||||
m_hLogFile.Open(FileName, eMode);
|
m_hLogFile.Open(FileName, eMode);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ class CTraceFileLog : public CTraceModule
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CTraceFileLog (const char * FileName, bool FlushFile = true);
|
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 ();
|
virtual ~CTraceFileLog ();
|
||||||
|
|
||||||
void Write ( const char * Message, bool EndOfLine );
|
void Write ( const char * Message, bool EndOfLine );
|
||||||
|
|
Loading…
Reference in New Issue