Old fashion design for PC-104
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.1 KiB

4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. //----------------------------------------------------------------------------
  2. // Laser Guard Ltd.
  3. // Copyright � 2000-2002. All Rights Reserved.
  4. // Version 1.0 01/01/2000
  5. // Last modification: 08/10/2003
  6. // PROJECT:
  7. // SUBSYSTEM:
  8. // FILE: GETFILE.CPP
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of GETFILE.CPP
  13. //----------------------------------------------------------------------------
  14. #include "screen.h"
  15. #include "getfile.h"
  16. #include "..\LgLib\version.h"
  17. BOOL CGetFile::OnCommand( BYTE bOperation, PBYTE pBuffer, INT nCount )
  18. {
  19. #ifdef DEBUG_GRAPH_SCREEN
  20. m_nProgressPos++;
  21. if( m_nProgressPos == 64000 )
  22. {
  23. m_nProgressPos = 0;
  24. m_bProgressColor++;
  25. if( m_bProgressColor == 10 )
  26. m_bProgressColor = 1;
  27. }
  28. g_Screen[ m_nProgressPos ] = m_bProgressColor;
  29. #endif
  30. if( m_bOperation == bOperation )
  31. return TRUE;
  32. m_bOperation = bOperation;
  33. switch( m_bOperation & LGS::GF_OP_MASK )
  34. {
  35. case LGS::GF_OP_OK:
  36. return TRUE;
  37. case LGS::GF_OP_OPEN:
  38. // copy file name
  39. memcpy( m_pFileName, pBuffer, nCount );
  40. m_pFileName[nCount] = 0;
  41. // close previous incarnation
  42. if( m_pFile ) fclose( m_pFile );
  43. // open temp file
  44. m_pFile = fopen( LGS_GETFILE_TEMP_NAME, "wb" );
  45. if( m_pFile )
  46. return TRUE;
  47. break;
  48. case LGS::GF_OP_DATA:
  49. if( m_pFile )
  50. {
  51. // write new portion
  52. fwrite( pBuffer, 1, nCount, m_pFile );
  53. return TRUE;
  54. }
  55. break;
  56. case LGS::GF_OP_CLOSE:
  57. if( m_pFile )
  58. {
  59. // close file
  60. fclose( m_pFile );
  61. m_pFile = NULL;
  62. // clear readonly flags (if any)
  63. _rtl_chmod( m_pFileName, 1, FA_ARCH );
  64. // delete old file
  65. remove( m_pFileName );
  66. // rename to distination name
  67. rename( LGS_GETFILE_TEMP_NAME, m_pFileName );
  68. return TRUE;
  69. }
  70. break;
  71. default:
  72. break;
  73. }
  74. return FALSE;
  75. }
  76. void CGetFile::Reset()
  77. {
  78. m_bOperation = 0xFF;
  79. if( m_pFile )
  80. {
  81. fclose( m_pFile );
  82. m_pFile = NULL;
  83. }
  84. memset( m_pFileName, 0, sizeof(m_pFileName) );
  85. #ifdef DEBUG_GRAPH_SCREEN
  86. m_nProgressPos = 0;
  87. m_bProgressColor = 1;
  88. #endif
  89. }