78 lines
2.3 KiB
C++
78 lines
2.3 KiB
C++
// Copyright (c) .NET Foundation. All rights reserved.
|
|
// Licensed under the MIT License. See License.txt in the project root for license information.
|
|
|
|
#include "precomp.hxx"
|
|
|
|
APPLICATION::~APPLICATION()
|
|
{
|
|
if (m_pAppOfflineHtm != NULL)
|
|
{
|
|
m_pAppOfflineHtm->DereferenceAppOfflineHtm();
|
|
m_pAppOfflineHtm = NULL;
|
|
}
|
|
|
|
if (m_pFileWatcherEntry != NULL)
|
|
{
|
|
// Mark the entry as invalid,
|
|
// StopMonitor will close the file handle and trigger a FCN
|
|
// the entry will delete itself when processing this FCN
|
|
m_pFileWatcherEntry->MarkEntryInValid();
|
|
m_pFileWatcherEntry->StopMonitor();
|
|
m_pFileWatcherEntry = NULL;
|
|
}
|
|
}
|
|
|
|
HRESULT
|
|
APPLICATION::StartMonitoringAppOffline()
|
|
{
|
|
HRESULT hr = S_OK;
|
|
if (m_pFileWatcherEntry != NULL)
|
|
{
|
|
hr = m_pFileWatcherEntry->Create(m_pConfiguration->QueryApplicationFullPath()->QueryStr(), L"app_offline.htm", this, NULL);
|
|
}
|
|
return hr;
|
|
}
|
|
|
|
VOID
|
|
APPLICATION::UpdateAppOfflineFileHandle()
|
|
{
|
|
STRU strFilePath;
|
|
PATH::ConvertPathToFullPath(L".\\app_offline.htm", m_pConfiguration->QueryApplicationFullPath()->QueryStr(), &strFilePath);
|
|
APP_OFFLINE_HTM *pOldAppOfflineHtm = NULL;
|
|
APP_OFFLINE_HTM *pNewAppOfflineHtm = NULL;
|
|
|
|
if (INVALID_FILE_ATTRIBUTES == GetFileAttributes(strFilePath.QueryStr()) && GetLastError() == ERROR_FILE_NOT_FOUND)
|
|
{
|
|
m_fAppOfflineFound = FALSE;
|
|
}
|
|
else
|
|
{
|
|
m_fAppOfflineFound = TRUE;
|
|
pNewAppOfflineHtm = new APP_OFFLINE_HTM(strFilePath.QueryStr());
|
|
|
|
if ( pNewAppOfflineHtm != NULL )
|
|
{
|
|
if (pNewAppOfflineHtm->Load())
|
|
{
|
|
//
|
|
// loaded the new app_offline.htm
|
|
//
|
|
pOldAppOfflineHtm = (APP_OFFLINE_HTM *)InterlockedExchangePointer((VOID**)&m_pAppOfflineHtm, pNewAppOfflineHtm);
|
|
|
|
if (pOldAppOfflineHtm != NULL)
|
|
{
|
|
pOldAppOfflineHtm->DereferenceAppOfflineHtm();
|
|
pOldAppOfflineHtm = NULL;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// ignored the new app_offline file because the file does not exist.
|
|
pNewAppOfflineHtm->DereferenceAppOfflineHtm();
|
|
pNewAppOfflineHtm = NULL;
|
|
}
|
|
}
|
|
|
|
OnAppOfflineHandleChange();
|
|
}
|
|
} |