bfiofile.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*
  2. ** Command & Conquer Generals Zero Hour(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /***********************************************************************************************
  19. *** 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 ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : Command & Conquer *
  23. * *
  24. * $Archive:: /Commando/Library/BFIOFILE.H $*
  25. * *
  26. * $Author:: Greg_h $*
  27. * *
  28. * $Modtime:: 7/22/97 11:37a $*
  29. * *
  30. * $Revision:: 1 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #ifndef BFIOFILE_H
  36. #define BFIOFILE_H
  37. #include "rawfile.h"
  38. /*
  39. ** This derivation of the raw file class handles buffering the input/output in order to
  40. ** achieve greater speed. The buffering is not active by default. It must be activated
  41. ** by setting the appropriate buffer through the Cache() function.
  42. */
  43. class BufferIOFileClass : public RawFileClass
  44. {
  45. typedef RawFileClass BASECLASS;
  46. public:
  47. BufferIOFileClass(char const * filename);
  48. BufferIOFileClass(void);
  49. virtual ~BufferIOFileClass(void);
  50. bool Cache( long size=0, void * ptr=NULL);
  51. void Free( void);
  52. bool Commit( void);
  53. virtual char const * Set_Name(char const * filename);
  54. virtual bool Is_Available(int forced=false);
  55. virtual bool Is_Open(void) const;
  56. virtual int Open(char const * filename, int rights=READ);
  57. virtual int Open(int rights=READ);
  58. virtual int Read(void * buffer, int size);
  59. virtual int Seek(int pos, int dir=SEEK_CUR);
  60. virtual int Size(void);
  61. virtual int Write(void const * buffer, int size);
  62. virtual void Close(void);
  63. enum {MINIMUM_BUFFER_SIZE=1024};
  64. private:
  65. bool IsAllocated;
  66. bool IsOpen;
  67. bool IsDiskOpen;
  68. bool IsCached;
  69. bool IsChanged;
  70. bool UseBuffer;
  71. int BufferRights;
  72. void *Buffer;
  73. long BufferSize;
  74. long BufferPos;
  75. long BufferFilePos;
  76. long BufferChangeBeg;
  77. long BufferChangeEnd;
  78. long FileSize;
  79. long FilePos;
  80. long TrueFileStart;
  81. };
  82. #endif