You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
103 lines
2.0 KiB
103 lines
2.0 KiB
//----------------------------------------------------------------------------
|
|
// Laser Guard Ltd.
|
|
// Copyright © 2000-2002. All Rights Reserved.
|
|
// Version 1.0 01/01/2000
|
|
// Last modification: 08/10/2003
|
|
// PROJECT:
|
|
// SUBSYSTEM:
|
|
// FILE: GETFILE.CPP
|
|
// AUTHOR: Sergey Chizhevskiy
|
|
// OVERVIEW
|
|
// ~~~~~~~~
|
|
// Source file of GETFILE.CPP
|
|
//----------------------------------------------------------------------------
|
|
#include "screen.h"
|
|
#include "getfile.h"
|
|
//#include "..\LgLib\version.h"
|
|
|
|
bool CGetFile::OnCommand( uint8_t bOperation, PBYTE pBuffer, int16_t nCount )
|
|
{
|
|
#ifdef DEBUG_GRAPH_SCREEN
|
|
m_nProgressPos++;
|
|
if( m_nProgressPos == 64000 )
|
|
{
|
|
m_nProgressPos = 0;
|
|
m_bProgressColor++;
|
|
if( m_bProgressColor == 10 )
|
|
m_bProgressColor = 1;
|
|
}
|
|
g_Screen[ m_nProgressPos ] = m_bProgressColor;
|
|
#endif
|
|
|
|
if( m_bOperation == bOperation )
|
|
return true;
|
|
|
|
m_bOperation = bOperation;
|
|
|
|
switch( m_bOperation & LGS::GF_OP_MASK )
|
|
{
|
|
case LGS::GF_OP_OK:
|
|
return true;
|
|
|
|
case LGS::GF_OP_OPEN:
|
|
// copy file name
|
|
memcpy( m_pFileName, pBuffer, nCount );
|
|
m_pFileName[nCount] = 0;
|
|
|
|
// close previous incarnation
|
|
if( m_pFile ) fclose( m_pFile );
|
|
|
|
// open temp file
|
|
m_pFile = fopen( LGS_GETFILE_TEMP_NAME, "wb" );
|
|
if( m_pFile )
|
|
return true;
|
|
break;
|
|
|
|
case LGS::GF_OP_DATA:
|
|
if( m_pFile )
|
|
{
|
|
// write new portion
|
|
fwrite( pBuffer, 1, nCount, m_pFile );
|
|
return true;
|
|
}
|
|
break;
|
|
|
|
case LGS::GF_OP_CLOSE:
|
|
if( m_pFile )
|
|
{
|
|
// close file
|
|
fclose( m_pFile );
|
|
m_pFile = NULL;
|
|
// clear readonly flags (if any)
|
|
_chmod( m_pFileName, 1, FA_ARCH );
|
|
// delete old file
|
|
remove( m_pFileName );
|
|
// rename to distination name
|
|
rename( LGS_GETFILE_TEMP_NAME, m_pFileName );
|
|
return true;
|
|
}
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
void CGetFile::Reset()
|
|
{
|
|
m_bOperation = 0xFF;
|
|
if( m_pFile )
|
|
{
|
|
fclose( m_pFile );
|
|
m_pFile = NULL;
|
|
}
|
|
memset( m_pFileName, 0, sizeof(m_pFileName) );
|
|
|
|
#ifdef DEBUG_GRAPH_SCREEN
|
|
m_nProgressPos = 0;
|
|
m_bProgressColor = 1;
|
|
#endif
|
|
}
|
|
|