BFIOFILE.H (3972B)
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 9 // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed 10 // in the hope that it will be useful, but with permitted additional restrictions 11 // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT 12 // distributed with this program. You should have received a copy of the 13 // GNU General Public License along with permitted additional restrictions 14 // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection 15 16 /* $Header: /CounterStrike/BFIOFILE.H 1 3/03/97 10:24a Joe_bostic $ */ 17 /*********************************************************************************************** 18 *** 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 *** 19 *********************************************************************************************** 20 * * 21 * Project Name : Westwood Library * 22 * * 23 * File Name : BFIOFILE.H * 24 * * 25 * Programmer : David R. Dettmer * 26 * * 27 * Start Date : November 10, 1995 * 28 * * 29 * Last Update : November 10, 1995 [DRD] * 30 * * 31 *---------------------------------------------------------------------------------------------* 32 * Functions: * 33 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ 34 35 #ifndef BFIOFILE_H 36 #define BFIOFILE_H 37 38 #include "rawfile.h" 39 40 /* 41 ** This derivation of the raw file class handles buffering the input/output in order to 42 ** achieve greater speed. The buffering is not active by default. It must be activated 43 ** by setting the appropriate buffer through the Cache() function. 44 */ 45 class BufferIOFileClass : public RawFileClass 46 { 47 public: 48 49 BufferIOFileClass(char const *filename); 50 BufferIOFileClass(void); 51 virtual ~BufferIOFileClass(void); 52 53 bool Cache( long size=0, void *ptr=NULL ); 54 void Free( void ); 55 bool Commit( void ); 56 virtual char const * Set_Name(char const *filename); 57 virtual int Is_Available(int forced=false); 58 virtual int Is_Open(void) const; 59 virtual int Open(char const *filename, int rights=READ); 60 virtual int Open(int rights=READ); 61 virtual long Read(void *buffer, long size); 62 virtual long Seek(long pos, int dir=SEEK_CUR); 63 virtual long Size(void); 64 virtual long Write(void const *buffer, long size); 65 virtual void Close(void); 66 67 enum {MINIMUM_BUFFER_SIZE=1024}; 68 69 private: 70 71 unsigned IsAllocated:1; 72 unsigned IsOpen:1; 73 unsigned IsDiskOpen:1; 74 unsigned IsCached:1; 75 unsigned IsChanged:1; 76 unsigned UseBuffer:1; 77 78 int BufferRights; 79 80 void *Buffer; 81 82 long BufferSize; 83 long BufferPos; 84 long BufferFilePos; 85 long BufferChangeBeg; 86 long BufferChangeEnd; 87 long FileSize; 88 long FilePos; 89 long TrueFileStart; 90 }; 91 92 #endif