CnC_Remastered_Collection

Command and Conquer: Red Alert
Log | Files | Refs | README | LICENSE

CCFILE.H (5168B)


      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:   F:\projects\c&c\vcs\code\ccfile.h_v   2.18   16 Oct 1995 16:45:28   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 
     43 
     44 /*
     45 **	This derived class for file access knows about mixfiles (packed files). It can handle opening
     46 **	a file that is embedded within a mixfile. This is true if the mixfile is cached or resides on
     47 **	disk. It is functionally similar to pakfiles, except much faster and less RAM intensive.
     48 */
     49 class CCFileClass : public CDFileClass
     50 {
     51 	public:
     52 		CCFileClass(char const *filename);
     53 		CCFileClass(void);
     54 		virtual ~CCFileClass(void) {};
     55 
     56 		// Delete should be overloaded here as well. Don't allow deletes of mixfiles.
     57 		
     58 		virtual int Open(char const *filename, int rights=READ) {Set_Name(filename);return Open(rights);};
     59 		virtual int Open(int rights=READ);
     60 		virtual int Is_Open(void) const;
     61 		virtual int Is_Available(int forced=false);
     62 		virtual long Read(void *buffer, long size);
     63 		virtual long Seek(long pos, int dir=SEEK_CUR);
     64 		virtual long Size(void);
     65 		virtual long Write(void const *buffer, long size);
     66 		virtual void Close(void);
     67 		virtual void Error(int error, int canretry = false, char const * filename=NULL);
     68 
     69 	private:
     70 
     71 		/*
     72 		**	This flag indicates that the file is part of a mixfile and the mixfile resides on
     73 		**	disk. The file handle for this file is a legitimate DOS handle, although special
     74 		**	handling is necessary that takes into account the embedded nature of the file.
     75 		*/
     76 		bool FromDisk;
     77 
     78 		/*
     79 		**	This indicates the file is actually part of a resident image of the mixfile
     80 		**	itself. In this case, the embedded file handle is invalid. All file access actually
     81 		**	gets routed through the cached version of the file. This is a pointer to the start
     82 		**	of the RAM image of the file.
     83 		*/
     84 		void * Pointer;
     85 
     86 		/*
     87 		**	This is the starting offset of the beginning of the file. This value is only valid
     88 		**	if the file is part of a mixfile that resides on disk. It serves as the counterpart
     89 		**	to the "Pointer" variable.
     90 		*/
     91 		long Start;
     92 
     93 		/*
     94 		**	This is the current seek position of the file. It is duplicated here if the file is
     95 		**	part of a mixfile since the DOS seek position is not accurate. This value will
     96 		**	range from zero to the size of the file in bytes.
     97 		*/
     98 		long Position;
     99 
    100 		/*
    101 		**	This is the size of the file if it was embedded in a mixfile. The size must be manually
    102 		**	kept track of because the DOS file size is invalid.
    103 		*/
    104 		long Length;
    105 
    106 		// Force these to never be invoked.
    107 		CCFileClass const operator = (CCFileClass const & c);
    108 		CCFileClass (CCFileClass const & ) {};
    109 };
    110 
    111 #endif