#include "StdAfx.h"
|
#include "NfsDriveRenewer.h"
|
|
|
CNfsDriveRenewer::CNfsDriveRenewer(DWORD dwInterval, INfsDriveRenewer2Parent* pNDR2P) : m_pNDR2P(pNDR2P), CTimerThreadPools(dwInterval)
|
{
|
}
|
|
CNfsDriveRenewer::~CNfsDriveRenewer(void)
|
{
|
|
}
|
|
void CNfsDriveRenewer::AddDrivePath( const CString& strDrivePath )
|
{
|
CSingleLock localLock(&m_csDrivePath);
|
localLock.Lock();
|
|
m_vecDrivePath.push_back(strDrivePath);
|
}
|
|
void CNfsDriveRenewer::TimerThreadProcess( PVOID pParameter )
|
{
|
CSingleLock localLock(&m_csDrivePath);
|
localLock.Lock();
|
|
RenewDrivePath();
|
}
|
|
void CNfsDriveRenewer::RenewDrivePath()
|
{
|
for (VectorStringIt it=m_vecDrivePath.begin(); it!=m_vecDrivePath.end(); it++)
|
{
|
CString strDrivePath = *it;
|
|
if (strDrivePath.GetLength()<1) continue;
|
CString strFilename = strDrivePath + _T("\\RenewFile.txt");
|
|
FILE *fp = NULL;
|
_tfopen_s(&fp, strFilename, _T("w"));
|
if (fp==NULL)
|
{
|
if (m_pNDR2P)
|
{
|
m_pNDR2P->NDR2P_SendDriveDisconnected(strDrivePath);
|
}
|
continue;
|
}
|
|
CTime time = CTime::GetCurrentTime();
|
_ftprintf_s(fp, _T("%04d-%02d-%02d - %02d:%02d:%02d"),
|
time.GetYear(), time.GetMonth(), time.GetDay(),
|
time.GetHour(), time.GetMinute(), time.GetSecond());
|
|
fclose(fp);
|
}
|
}
|
|
BOOL CNfsDriveRenewer::StartThread()
|
{
|
return CTimerThreadPools::StartThread();
|
}
|
|
void CNfsDriveRenewer::StopThread()
|
{
|
CTimerThreadPools::StopThread();
|
}
|