//---------------------------------------------------------------------------- // Laser Guard Ltd. // Copyright © 2000-2002. All Rights Reserved. // Version 1.0 01/01/2000 // Last modification: 05/11/2003 // PROJECT: // SUBSYSTEM: // FILE: LgReportSetupSettings.cpp // AUTHOR: Sergey Chizhevskiy // OVERVIEW // ~~~~~~~~ // Source file of LgReportSetupSettings.cpp //---------------------------------------------------------------------------- #include "stdafx.h" #include "LgReportSetupSettings.h" #ifdef _DEBUG #undef THIS_FILE static char THIS_FILE[]=__FILE__; #define new DEBUG_NEW #endif CLgReportSettings::CLgReportSettings() { m_Settings.bAccessEnable = FALSE; m_Settings.wAccessPort = 3000; _tcsncpy( m_Settings.pAccessName, _T("Local"), MAX_PATH ); } BOOL CLgReportSettings::Load( LPCTSTR pFileName ) { // delete old contents RemoveAll(); FILE *pFile = _tfopen( pFileName, _T("rb") ); if( !pFile ) return FALSE; if( fread( &m_Settings, 1, sizeof(m_Settings), pFile ) != sizeof(m_Settings) ) { fclose( pFile ); return FALSE; } INT nCount = 0; if( fread( &nCount, 1, sizeof(INT), pFile ) != sizeof(INT) ) { fclose( pFile ); return FALSE; } for( INT i = 0; i < nCount; i++ ) { CLgReportSiteInfo si; if( fread( &si, 1, sizeof(CLgReportSiteInfo), pFile ) != sizeof(CLgReportSiteInfo) ) { fclose( pFile ); return FALSE; } Add( si ); } fclose( pFile ); return TRUE; } BOOL CLgReportSettings::Store( LPCTSTR pFileName ) { FILE *pFile = _tfopen( pFileName, _T("wb") ); if( !pFile ) return FALSE; fwrite( &m_Settings, 1, sizeof(m_Settings), pFile ); INT nCount = GetCount(); fwrite( &nCount, 1, sizeof(INT), pFile ); for( INT i = 0; i < nCount; i++ ) fwrite( &GetAt(i), 1, sizeof(CLgReportSiteInfo), pFile ); fclose( pFile ); return TRUE; }