// **************************************************************************
// ** **
// ** **
// ** **
// ** Name: UTILITY FUNCTIONS **
// ** **
// ** Description: **
// ** **
// ** **
// ** Parameters: **
// ** **
// ** **
// ** Returns: **
// ** **
// ** **
// ** **
// ** **
// **************************************************************************
void CUpdateViaHttp::LaunchUpdate()
{
CFile tFile;
DWORD dwLastError;
BOOL fRC = FALSE;
CString csCommandLine;
char *pszTempName = NULL;
pszTempName = _tempnam((char *)(LPCTSTR) m_csLoaderBaseDir, m_csFname );
// ---> -------------------------- <---
// ---> Validate call to tempnam() <---
// ---> -------------------------- <---
if ( pszTempName != NULL )
{
// _splitpath( pszTempName,
// szDrive,
// szDir,
// szFname,
// szExt );
// csApplicationDir = szDrive;
// csApplicationDir += szDir;
// Save the temp file name
m_csTempPath = pszTempName;
// ---> --------------- <---
// ---> Load the loader <---
// ---> --------------- <---
fRC = CreateLoaderFile( LOADER_FILENAME );
if ( fRC == TRUE )
{
// ---> --------------------------------- <---
// ---> Copy from internal to Destination <---
// ---> --------------------------------- <---
fRC = tFile.Open( pszTempName, CFile::modeCreate | CFile::modeWrite | CFile::shareExclusive | CFile::typeBinary );
if ( fRC )
{
tFile.Write( m_pabClientDownloadFileData, m_dwClientDownloadFileSize );
tFile.Close();
//fRC = TRUE;
// Temp Files is loaded - Now create
// loader -D xx -R sr dn -E ex cl
csCommandLine.Format( "\"%s\" %s \"%s\" %s \"%s\" \"%s\" %s \"%s\" %s",
m_csLoaderFilePath,
UPD_PARAM_DELETE, m_csClientFullPathName,
UPD_PARAM_RENAME, m_csTempPath, m_csClientFullPathName,
UPD_PARAM_EXECUTE, m_csClientFullPathName, "\"\"" );
// Create Loader Command Line
fRC = LaunchLoader( (char *)(LPCTSTR)m_csLoaderFilePath,
(char *)(LPCTSTR)csCommandLine,
(char *)(LPCTSTR)m_csLoaderBaseDir );
if ( fRC == TRUE )
{
// Launch is successful
PostMessageToParent( ExitNow, 0 );
PostQuitMessage( 0 );
}
else
{
unlink( pszTempName );
// }
# ifdef LOG_ENABLE
// else
// {
//dwLastError = GetLastError();
ON_LOG_ERROR( va_string( " ** Launch Loader FAILS\n" ));
// }
# endif //ifdef LOG_ENABLE
}
}
# ifdef LOG_ENABLE
else
{
dwLastError = GetLastError();
ON_LOG_ERROR( va_string( " ** Create Temp File FAILS (%ld)\n", dwLastError ));
}
# endif //ifdef LOG_ENABLE
}
# ifdef LOG_ENABLE
else
{
dwLastError = GetLastError();
ON_LOG_ERROR( va_string( " ** CreateLoaderFile FAILS (%ld)\n", dwLastError ));
}
# endif //ifdef LOG_ENABLE
}
# ifdef LOG_ENABLE
else
{
dwLastError = GetLastError();
ON_LOG_ERROR( va_string( " ** Create Temp Name fails (%ld)\n", dwLastError ));
}
// ON_LOG_FUNCTION( va_string( "<-- CUpdateClient::UpdateClient( %s, %p, %ld )\n", pszApplicationPath, pbDownloadBuffer, dwDownloadSize));
# endif //ifdef LOG_ENABLE
// return fRC;
}