CDFILE.H 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*
  2. ** Command & Conquer(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. /* $Header: F:\projects\c&c\vcs\code\cdfile.h_v 2.20 16 Oct 1995 16:45:58 JOE_BOSTIC $ */
  19. /***********************************************************************************************
  20. *** 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 ***
  21. ***********************************************************************************************
  22. * *
  23. * Project Name : Westwood LIbrary *
  24. * *
  25. * File Name : CDFILE.H *
  26. * *
  27. * Programmer : Joe L. Bostic *
  28. * *
  29. * Start Date : October 18, 1994 *
  30. * *
  31. * Last Update : October 18, 1994 [JLB] *
  32. * *
  33. *---------------------------------------------------------------------------------------------*
  34. * Functions: *
  35. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  36. #ifndef CDFILE_H
  37. #define CDFILE_H
  38. #include <dos.h>
  39. #include "rawfile.h"
  40. /*
  41. ** This class is derived from the raw file class. This class adds the functionality of searching
  42. ** across multiple directories or drives. It is designed for the typical case of a CD-ROM game
  43. ** were some data exists in the current directory (hard drive) and the rest exists on the CD-ROM.
  44. ** Searching for the file occurs by first examining the current directory. If the file does not
  45. ** exist there, then all the paths available are examined in turn until the file can be found.
  46. ** For opening files to write, only the current directory is examined. The directory search order
  47. ** is controlled by the path list as submitted to Set_Search_Drives(). The format of the path
  48. ** string is the same as the DOS path string.
  49. */
  50. class CDFileClass : public RawFileClass
  51. {
  52. public:
  53. CDFileClass(char const *filename);
  54. CDFileClass(void);
  55. virtual ~CDFileClass(void) {};
  56. virtual char const * Set_Name(char const *filename);
  57. virtual int Open(char const *filename, int rights=READ);
  58. virtual int Open(int rights=READ);
  59. void Searching(int on) {IsDisabled = !on;};
  60. static bool Is_There_Search_Drives(void) {return(First != NULL);};
  61. static int Set_Search_Drives(char * pathlist);
  62. static void Add_Search_Drive(char *path);
  63. static void Clear_Search_Drives(void);
  64. static void Refresh_Search_Drives(void);
  65. static void Set_CD_Drive(int drive);
  66. static int Get_CD_Drive(void) {return(CurrentCDDrive);};
  67. static int Get_Last_CD_Drive(void) {return(LastCDDrive);};
  68. private:
  69. /*
  70. ** Is multi-drive searching disabled for this file object?
  71. */
  72. unsigned IsDisabled:1;
  73. /*
  74. ** This is the control record for each of the drives specified in the search
  75. ** path. There can be many such search paths available.
  76. */
  77. typedef struct {
  78. void * Next; // Pointer to next search record.
  79. char const * Path; // Pointer to path string.
  80. } SearchDriveType;
  81. /*
  82. ** This points to the first path record.
  83. */
  84. static SearchDriveType * First;
  85. /*
  86. ** This is a copy of the unparsed search path list
  87. */
  88. static char RawPath[512];
  89. /*
  90. ** The drive letter of the current cd drive
  91. */
  92. static int CurrentCDDrive;
  93. /*
  94. ** The drive letter of the last used CD drive
  95. */
  96. static int LastCDDrive;
  97. };
  98. #endif