bufffile.h 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. ** Command & Conquer Renegade(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/Code/wwlib/bufffile.h $*
  25. * *
  26. * $Author:: Ian_l $*
  27. * *
  28. * $Modtime:: 10/31/01 3:33p $*
  29. * *
  30. * $Revision:: 3 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * RawFileClass::File_Name -- Returns with the filename associate with the file object. *
  35. * RawFileClass::RawFileClass -- Default constructor for a file object. *
  36. * RawFileClass::~RawFileClass -- Default deconstructor for a file object. *
  37. * RawFileClass::Is_Open -- Checks to see if the file is open or not. *
  38. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  39. #if _MSC_VER >= 1000
  40. #pragma once
  41. #endif // _MSC_VER >= 1000
  42. #ifndef BUFFFILE_H
  43. #define BUFFFILE_H
  44. #include "rawfile.h"
  45. /*
  46. ** This is the definition of a buffered read raw file class.
  47. */
  48. class BufferedFileClass : public RawFileClass
  49. {
  50. typedef RawFileClass BASECLASS;
  51. public:
  52. BufferedFileClass(char const *filename);
  53. BufferedFileClass(void);
  54. BufferedFileClass (RawFileClass const & f);
  55. BufferedFileClass & operator = (BufferedFileClass const & f);
  56. virtual ~BufferedFileClass(void);
  57. virtual int Read(void *buffer, int size);
  58. virtual int Seek(int pos, int dir=SEEK_CUR);
  59. virtual int Write(void const *buffer, int size);
  60. virtual void Close(void);
  61. protected:
  62. static void Set_Desired_Buffer_Size( int size ) { _DesiredBufferSize = size; }
  63. void Reset_Buffer( void );
  64. private:
  65. unsigned char * Buffer; // The read buffer
  66. unsigned int BufferSize; // The allocated size of the read buffer
  67. int BufferAvailable; // The amount of data in the read buffer
  68. int BufferOffset; // The data already given out
  69. static int _DesiredBufferSize;
  70. };
  71. #endif