CnC_Remastered_Collection

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

CDFILE.H (5124B)


      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/CDFILE.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 : CDFILE.H                                                     *
     24  *                                                                                             *
     25  *                   Programmer : Joe L. Bostic                                                *
     26  *                                                                                             *
     27  *                   Start Date : October 18, 1994                                             *
     28  *                                                                                             *
     29  *                  Last Update : October 18, 1994   [JLB]                                     *
     30  *                                                                                             *
     31  *---------------------------------------------------------------------------------------------*
     32  * Functions:                                                                                  *
     33  * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
     34 
     35 #ifndef CDFILE_H
     36 #define CDFILE_H
     37 
     38 #include	<dos.h>
     39 #include	"bfiofile.h"
     40 
     41 /*
     42 **	This class is derived from the BufferIOFileClass. This class adds the functionality of searching
     43 **	across multiple directories or drives. It is designed for the typical case of a CD-ROM game
     44 **	were some data exists in the current directory (hard drive) and the rest exists on the CD-ROM.
     45 **	Searching for the file occurs by first examining the current directory. If the file does not
     46 **	exist there, then all the paths available are examined in turn until the file can be found.
     47 **	For opening files to write, only the current directory is examined. The directory search order
     48 **	is controlled by the path list as submitted to Set_Search_Drives(). The format of the path
     49 **	string is the same as the DOS path string.
     50 */
     51 class CDFileClass : public BufferIOFileClass
     52 {
     53 	public:
     54 		CDFileClass(char const *filename);
     55 		CDFileClass(void);
     56 		virtual ~CDFileClass(void) {};
     57 
     58 		virtual char const * Set_Name(char const *filename);
     59 		virtual int Open(char const *filename, int rights=READ);
     60 		virtual int Open(int rights=READ);
     61 
     62 		void Searching(int on) {IsDisabled = !on;};
     63 
     64 		static bool Is_There_Search_Drives(void) {return(First != NULL);};
     65 		static int Set_Search_Drives(char * pathlist);
     66 		static void Add_Search_Drive(char *path);
     67 		static void Clear_Search_Drives(void);
     68 		static void Refresh_Search_Drives(void);
     69 		static void Set_CD_Drive(int drive);
     70 		static int  Get_CD_Drive(void) {return(CurrentCDDrive);};
     71 		static int  Get_Last_CD_Drive(void) {return(LastCDDrive);};
     72 
     73 		// RawPath will overflow if we keep setting the path. ST - 1/23/2019 11:12AM
     74 		static void Reset_Raw_Path(void) { RawPath[0] = 0; }
     75 
     76 		// Need to access the paths. ST - 3/15/2019 2:14PM
     77 		static const char *Get_Search_Path(int index);
     78 
     79 	private:
     80 
     81 		/*
     82 		**	Is multi-drive searching disabled for this file object?
     83 		*/
     84 		unsigned IsDisabled:1;
     85 
     86 		/*
     87 		**	This is the control record for each of the drives specified in the search
     88 		**	path. There can be many such search paths available.
     89 		*/
     90 		typedef struct {
     91 			void * Next;		// Pointer to next search record.
     92 			char const * Path;			// Pointer to path string.
     93 		} SearchDriveType;
     94 
     95 		/*
     96 		**	This points to the first path record.
     97 		*/
     98 		static SearchDriveType * First;
     99 		/*
    100 		** This is a copy of the unparsed search path list
    101 		*/
    102 		static char RawPath[512];
    103 
    104 		/*
    105 		** The drive letter of the current cd drive
    106 		*/
    107 		static int CurrentCDDrive;
    108 
    109 		/*
    110 		** The drive letter of the last used CD drive
    111 		*/
    112 		static int LastCDDrive;
    113 };
    114 
    115 #endif
    116