BFIOFILE.H 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. //
  2. // Copyright 2020 Electronic Arts Inc.
  3. //
  4. // TiberianDawn.DLL and RedAlert.dll and corresponding source code is free
  5. // software: you can redistribute it and/or modify it under the terms of
  6. // the GNU General Public License as published by the Free Software Foundation,
  7. // either version 3 of the License, or (at your option) any later version.
  8. // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
  9. // in the hope that it will be useful, but with permitted additional restrictions
  10. // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
  11. // distributed with this program. You should have received a copy of the
  12. // GNU General Public License along with permitted additional restrictions
  13. // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
  14. /* $Header: /CounterStrike/BFIOFILE.H 1 3/03/97 10:24a Joe_bostic $ */
  15. /***********************************************************************************************
  16. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  17. ***********************************************************************************************
  18. * *
  19. * Project Name : Westwood Library *
  20. * *
  21. * File Name : BFIOFILE.H *
  22. * *
  23. * Programmer : David R. Dettmer *
  24. * *
  25. * Start Date : November 10, 1995 *
  26. * *
  27. * Last Update : November 10, 1995 [DRD] *
  28. * *
  29. *---------------------------------------------------------------------------------------------*
  30. * Functions: *
  31. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  32. #ifndef BFIOFILE_H
  33. #define BFIOFILE_H
  34. #include "rawfile.h"
  35. /*
  36. ** This derivation of the raw file class handles buffering the input/output in order to
  37. ** achieve greater speed. The buffering is not active by default. It must be activated
  38. ** by setting the appropriate buffer through the Cache() function.
  39. */
  40. class BufferIOFileClass : public RawFileClass
  41. {
  42. public:
  43. BufferIOFileClass(char const *filename);
  44. BufferIOFileClass(void);
  45. virtual ~BufferIOFileClass(void);
  46. bool Cache( long size=0, void *ptr=NULL );
  47. void Free( void );
  48. bool Commit( void );
  49. virtual char const * Set_Name(char const *filename);
  50. virtual int Is_Available(int forced=false);
  51. virtual int Is_Open(void) const;
  52. virtual int Open(char const *filename, int rights=READ);
  53. virtual int Open(int rights=READ);
  54. virtual long Read(void *buffer, long size);
  55. virtual long Seek(long pos, int dir=SEEK_CUR);
  56. virtual long Size(void);
  57. virtual long Write(void const *buffer, long size);
  58. virtual void Close(void);
  59. enum {MINIMUM_BUFFER_SIZE=1024};
  60. private:
  61. unsigned IsAllocated:1;
  62. unsigned IsOpen:1;
  63. unsigned IsDiskOpen:1;
  64. unsigned IsCached:1;
  65. unsigned IsChanged:1;
  66. unsigned UseBuffer:1;
  67. int BufferRights;
  68. void *Buffer;
  69. long BufferSize;
  70. long BufferPos;
  71. long BufferFilePos;
  72. long BufferChangeBeg;
  73. long BufferChangeEnd;
  74. long FileSize;
  75. long FilePos;
  76. long TrueFileStart;
  77. };
  78. #endif