FILE.BAK 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. /*
  2. ** Command & Conquer Red Alert(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. /***************************************************************************
  19. ** C O N F I D E N T I A L --- W E S T W O O D A S S O C I A T E S **
  20. ***************************************************************************
  21. * *
  22. * Project Name : Library - Filio header stuff. *
  23. * *
  24. * File Name : FILE.H *
  25. * *
  26. * Programmer : Scott K. Bowen *
  27. * *
  28. * Start Date : September 13, 1993 *
  29. * *
  30. * Last Update : April 11, 1994 *
  31. * *
  32. *-------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #ifndef FILE_H
  36. #define FILE_H
  37. #ifndef ERROR
  38. #define ERROR -1
  39. #endif
  40. #ifndef FILETEMP_H
  41. // This should be removed once the library is all intacked.
  42. #include "filetemp.h"
  43. #endif
  44. /*=========================================================================*/
  45. /* File IO system defines and enumerations */
  46. /*=========================================================================*/
  47. #define XMAXPATH 80
  48. /*
  49. ** These are the Open_File, Read_File, and Seek_File constants.
  50. */
  51. #define READ 1 // Read access.
  52. #define WRITE 2 // Write access.
  53. #ifndef SEEK_SET
  54. #define SEEK_SET 0 // Seek from start of file.
  55. #define SEEK_CUR 1 // Seek relative from current location.
  56. #define SEEK_END 2 // Seek from end of file.
  57. #endif
  58. typedef enum {
  59. FILEB_PROCESSED=8,// Was the packed file header of this file processed?
  60. FILEB_PRELOAD, // Scan for and make file resident at WWDOS_Init time?
  61. FILEB_RESIDENT, // Make resident at Open_File time?
  62. FILEB_FLUSH, // Un-resident at Close_File time?
  63. FILEB_PACKED, // Is this file packed?
  64. FILEB_KEEP, // Don't ever flush this resident file?
  65. FILEB_PRIORITY, // Flush this file last?
  66. FILEB_LAST
  67. } FileFlags_Type;
  68. #define FILEF_NONE 0
  69. #define FILEF_PROCESSED (1<<FILEB_PROCESSED)
  70. #define FILEF_PRELOAD (1<<FILEB_PRELOAD)
  71. #define FILEF_RESIDENT (1<<FILEB_RESIDENT)
  72. #define FILEF_FLUSH (1<<FILEB_FLUSH)
  73. #define FILEF_PACKED (1<<FILEB_PACKED)
  74. #define FILEF_KEEP (1<<FILEB_KEEP)
  75. #define FILEF_PRIORITY (1<<FILEB_PRIORITY)
  76. /*
  77. ** These errors are returned by WWDOS_Init(). All errors encountered are
  78. ** or'd together so there may be more then one error returned. Not all
  79. ** errors are fatal, such as the cache errors.
  80. */
  81. typedef enum {
  82. FI_SUCCESS = 0x00,
  83. FI_CACHE_TOO_BIG = 0x01,
  84. FI_CACHE_ALREADY_INIT = 0x02,
  85. FI_FILEDATA_FILE_NOT_FOUND = 0x04,
  86. FI_FILEDATA_TOO_BIG = 0x08,
  87. FI_SEARCH_PATH_NOT_FOUND = 0x10,
  88. FI_STARTUP_PATH_NOT_FOUND = 0x20,
  89. FI_NO_CACHE_FOR_PRELOAD = 0x40,
  90. FI_FILETABLE_NOT_INIT = 0x80,
  91. } FileInitErrorType;
  92. /*
  93. ** These are the errors that are detected by the File I/O system and
  94. ** passed to the io error routine.
  95. */
  96. //lint -strong(AJX,FileErrorType)
  97. typedef enum {
  98. CANT_CREATE_FILE,
  99. BAD_OPEN_MODE,
  100. COULD_NOT_OPEN,
  101. TOO_MANY_FILES,
  102. CLOSING_NON_HANDLE,
  103. READING_NON_HANDLE,
  104. WRITING_NON_HANDLE,
  105. SEEKING_NON_HANDLE,
  106. SEEKING_BAD_OFFSET,
  107. WRITING_RESIDENT,
  108. UNKNOWN_INDEX,
  109. DID_NOT_CLOSE,
  110. FATAL_ERROR,
  111. FILE_NOT_LISTED,
  112. FILE_LENGTH_MISMATCH,
  113. INTERNAL_ERROR,
  114. MAKE_RESIDENT_ZERO_SIZE,
  115. RESIDENT_SORT_FAILURE,
  116. NUMBER_OF_ERRORS /* MAKE SURE THIS IS THE LAST ENTRY */
  117. } FileErrorType;
  118. // This is here tempararaly until library is put together.
  119. //extern WORD cdecl (*cdecl IO_Error)(FileErrorType error, BYTE const *filename);
  120. extern short (*Open_Error)(FileErrorType, BYTE const *);
  121. /*=========================================================================*/
  122. /* File IO system structures */
  123. /*=========================================================================*/
  124. //lint -strong(AJX,FileDataType)
  125. typedef struct {
  126. char *Name; // File name (include sub-directory but not volume).
  127. long Size; // File size (0=indeterminate).
  128. void *Ptr; // Resident file pointer.
  129. long Start; // Starting offset in DOS handle file.
  130. unsigned char Disk; // Disk number location.
  131. unsigned char OpenCount; // Count of open locks on resident file.
  132. unsigned short Flag; // File control flags.
  133. } FileDataType;
  134. /*=========================================================================*/
  135. /* FIle IO system globals. */
  136. /*=========================================================================*/
  137. // These are cpp errors in funtions declarations JULIO JEREZ
  138. // extern FileDataType cdecl FileData[];
  139. // extern BYTE cdecl ExecPath[XMAXPATH + 1];
  140. // extern BYTE cdecl DataPath[XMAXPATH + 1];
  141. // extern BYTE cdecl StartPath[XMAXPATH + 1];
  142. // extern BOOL cdecl UseCD;
  143. // The correct syntax is NO TYPE MODIFIER APPLY TO DATA DECLARATIONS
  144. extern FileDataType FileData[];
  145. extern char ExecPath[XMAXPATH + 1];
  146. extern char DataPath[XMAXPATH + 1];
  147. extern char StartPath[XMAXPATH + 1];
  148. extern BOOL UseCD;
  149. /*=========================================================================*/
  150. /* The following prototypes are for the file: FILEINIT.CPP */
  151. /*=========================================================================*/
  152. void cdecl WWDOS_Shutdown(void);
  153. FileInitErrorType cdecl WWDOS_Init(unsigned long cachesize, char *filedata, char *cdpath);
  154. /*=========================================================================*/
  155. /* The following prototypes are for the file: FILE.CPP */
  156. /*=========================================================================*/
  157. int cdecl Open_File(char const *file_name, short mode);
  158. void cdecl Close_File(short handle);
  159. long cdecl Read_File(short handle, void *buf, unsigned long bytes);
  160. long cdecl Write_File(short handle, void const *buf, unsigned long bytes);
  161. unsigned long cdecl Seek_File(short handle, long offset, short starting);
  162. int cdecl File_Exists(char const *file_name);
  163. unsigned long cdecl File_Size(short handle);
  164. BOOL cdecl Is_Handle_Valid(short handle, FileErrorType error, char const *name);
  165. short cdecl Open_File_With_Recovery( char const *file_name, unsigned short mode );
  166. /*=========================================================================*/
  167. /* The following prototypes are for the file: FILECACH.CPP */
  168. /*=========================================================================*/
  169. void Unfragment_File_Cache(void);
  170. BOOL cdecl Make_File_Resident(char const *filename);
  171. short cdecl Flush_Unused_File_Cache(short flush_keeps);
  172. BOOL cdecl Free_Resident_File(char const *file);
  173. /*=========================================================================*/
  174. /* The following prototypes are for the file: FILECHNG.CPP */
  175. /*=========================================================================*/
  176. short cdecl Create_File(char const *file_name);
  177. short cdecl Delete_File(char const *file_name);
  178. BOOL cdecl Change_File_Size(short handle, unsigned long new_size);
  179. /*=========================================================================*/
  180. /* The following prototypes are for the file: FILEINFO.CPP */
  181. /*=========================================================================*/
  182. short cdecl Get_DOS_Handle(short fh);
  183. short cdecl Free_Handles(void);
  184. short cdecl Find_Disk_Number(char const *file_name);
  185. short cdecl Set_File_Flags(char const *filename, short flags);
  186. short cdecl Clear_File_Flags(char const *filename, short flags);
  187. short cdecl Get_File_Flags(char const *filename);
  188. BOOL cdecl Multi_Drive_Search(BOOL on);
  189. /*=========================================================================*/
  190. /* The following prototypes are for the file: FINDFILE.CPP */
  191. /*=========================================================================*/
  192. short cdecl Find_File(char const *file_name);
  193. short cdecl Find_File_Index(char const *filename);
  194. /*=========================================================================*/
  195. /* The following prototypes are for the file: FFIRST.ASM */
  196. /*=========================================================================*/
  197. #include <dos.h>
  198. #ifdef __cplusplus
  199. extern "C" {
  200. #endif
  201. extern short Find_First(unsigned char *fname, unsigned short mode, struct find_t *ffblk);
  202. extern short Find_Next(struct find_t *ffblk);
  203. #ifdef __cplusplus
  204. }
  205. #endif
  206. #endif // FILE_H
  207.