CCFILE.H (4890B)
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/CCFILE.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 : Command & Conquer * 22 * * 23 * File Name : CCFILE.H * 24 * * 25 * Programmer : Joe L. Bostic * 26 * * 27 * Start Date : October 17, 1994 * 28 * * 29 * Last Update : October 17, 1994 [JLB] * 30 * * 31 *---------------------------------------------------------------------------------------------* 32 * Functions: * 33 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ 34 35 #ifndef CCFILE_H 36 #define CCFILE_H 37 38 //#include <wwlib32.h> 39 #include <limits.h> 40 #include "mixfile.h" 41 #include "cdfile.h" 42 #include "buff.h" 43 44 45 /* 46 ** This derived class for file access knows about mixfiles (packed files). It can handle opening 47 ** a file that is embedded within a mixfile. This is true if the mixfile is cached or resides on 48 ** disk. It is functionally similar to pakfiles, except much faster and less RAM intensive. 49 */ 50 class CCFileClass : public CDFileClass 51 { 52 public: 53 CCFileClass(char const * filename); 54 CCFileClass(void); 55 virtual ~CCFileClass(void) {Position = 0;}; 56 57 // Delete should be overloaded here as well. Don't allow deletes of mixfiles. 58 59 bool Is_Resident(void) const {return(Data.Get_Buffer() != NULL);} 60 virtual int Is_Available(int forced=false); 61 virtual int Is_Open(void) const; 62 virtual int Open(char const * filename, int rights=READ) {Set_Name(filename);return Open(rights);}; 63 virtual int Open(int rights=READ); 64 virtual long Read(void * buffer, long size); 65 virtual long Seek(long pos, int dir=SEEK_CUR); 66 virtual long Size(void); 67 virtual long Write(void const * buffer, long size); 68 virtual void Close(void); 69 virtual unsigned long Get_Date_Time(void); 70 virtual bool Set_Date_Time(unsigned long datetime); 71 virtual void Error(int error, int canretry = false, char const * filename=NULL); 72 73 private: 74 75 /* 76 ** This indicates the file is actually part of a resident image of the mixfile 77 ** itself. In this case, the embedded file handle is invalid. All file access actually 78 ** gets routed through the cached version of the file. This is a pointer to the start 79 ** of the RAM image of the file. 80 */ 81 ::Buffer Data; 82 // void * Pointer; 83 84 /* 85 ** This is the size of the file if it was embedded in a mixfile. The size must be manually 86 ** kept track of because the DOS file size is invalid. 87 */ 88 // long Length; 89 90 /* 91 ** This is the current seek position of the file. It is duplicated here if the file is 92 ** part of a mixfile since the DOS seek position is not accurate. This value will 93 ** range from zero to the size of the file in bytes. 94 */ 95 long Position; 96 97 // Force these to never be invoked. 98 CCFileClass const & operator = (CCFileClass const & c); 99 CCFileClass (CCFileClass const & ); 100 }; 101 102 template <> class MixFileClass<CDFileClass>; 103 104 #endif