CDFILE.H 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
  9. // in the hope that it will be useful, but with permitted additional restrictions
  10. // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
  11. // distributed with this program. You should have received a copy of the
  12. // GNU General Public License along with permitted additional restrictions
  13. // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
  14. /* $Header: /CounterStrike/CDFILE.H 1 3/03/97 10:24a Joe_bostic $ */
  15. /***********************************************************************************************
  16. *** 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 ***
  17. ***********************************************************************************************
  18. * *
  19. * Project Name : Westwood LIbrary *
  20. * *
  21. * File Name : CDFILE.H *
  22. * *
  23. * Programmer : Joe L. Bostic *
  24. * *
  25. * Start Date : October 18, 1994 *
  26. * *
  27. * Last Update : October 18, 1994 [JLB] *
  28. * *
  29. *---------------------------------------------------------------------------------------------*
  30. * Functions: *
  31. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  32. #ifndef CDFILE_H
  33. #define CDFILE_H
  34. #include <dos.h>
  35. #include "bfiofile.h"
  36. /*
  37. ** This class is derived from the BufferIOFileClass. This class adds the functionality of searching
  38. ** across multiple directories or drives. It is designed for the typical case of a CD-ROM game
  39. ** were some data exists in the current directory (hard drive) and the rest exists on the CD-ROM.
  40. ** Searching for the file occurs by first examining the current directory. If the file does not
  41. ** exist there, then all the paths available are examined in turn until the file can be found.
  42. ** For opening files to write, only the current directory is examined. The directory search order
  43. ** is controlled by the path list as submitted to Set_Search_Drives(). The format of the path
  44. ** string is the same as the DOS path string.
  45. */
  46. class CDFileClass : public BufferIOFileClass
  47. {
  48. public:
  49. CDFileClass(char const *filename);
  50. CDFileClass(void);
  51. virtual ~CDFileClass(void) {};
  52. virtual char const * Set_Name(char const *filename);
  53. virtual int Open(char const *filename, int rights=READ);
  54. virtual int Open(int rights=READ);
  55. void Searching(int on) {IsDisabled = !on;};
  56. static bool Is_There_Search_Drives(void) {return(First != NULL);};
  57. static int Set_Search_Drives(char * pathlist);
  58. static void Add_Search_Drive(char *path);
  59. static void Clear_Search_Drives(void);
  60. static void Refresh_Search_Drives(void);
  61. static void Set_CD_Drive(int drive);
  62. static int Get_CD_Drive(void) {return(CurrentCDDrive);};
  63. static int Get_Last_CD_Drive(void) {return(LastCDDrive);};
  64. // RawPath will overflow if we keep setting the path. ST - 1/23/2019 11:12AM
  65. static void Reset_Raw_Path(void) { RawPath[0] = 0; }
  66. // Need to access the paths. ST - 3/15/2019 2:14PM
  67. static const char *Get_Search_Path(int index);
  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