![]() |
Initialize() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
| Public Function |
Declared in: FileLog.h |
Declaration
BOOL Initialize(
const std::string& rFileName);
DescriptionInitialize the log
Function Body
//Open's the log file
try
{
//Check if the file is open
if (m_pFile)
//close is
fclose(m_pFile);
//Which open mode
BOOL bTruncate;
bTruncate=FALSE;
//Do we need to get the file size
if (m_dwMaxLogSize)
{
//Open the file
HANDLE hFile;
hFile=CreateFile(rFileName.c_str(),
GENERIC_READ,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL);
//Do we have it?
if (hFile!=INVALID_HANDLE_VALUE)
{
//Get the file size
DWORD dwSize;
dwSize=GetFileSize(hFile,
NULL);
//Close the file
CloseHandle(hFile);
//Is it bigger
if (dwSize>m_dwMaxLogSize)
bTruncate=FALSE;
}
}
//Now open the file
if (!bTruncate)
m_pFile=fopen(rFileName.c_str(),"at");
else
m_pFile=fopen(rFileName.c_str(),"wt");
//Did we manage to open it?
if (!m_pFile)
return FALSE;
else
return TRUE;
}
ERROR_UNKNOWN_RETURN("ReportError",FALSE)
See Also
This web site was generated
using Surveyor V4.50.811.1. Click
here
for more information. |
Site content copyright © 2003 Komodia LTD.. See the About page for additional notices. This page last updated: 24 Feb 2003. |