_FILE.H 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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. #include "file.h"
  37. #endif
  38. #ifndef _FILE_H
  39. #define _FILE_H
  40. /*=========================================================================*/
  41. /* Fileio defines */
  42. /*=========================================================================*/
  43. #define LIB_CDROM TRUE
  44. #define MODE_OLDFILE (O_RDONLY | O_BINARY)
  45. #define MODE_NEWFILE (O_WRONLY | O_BINARY | O_CREAT | O_TRUNC)
  46. #define MODE_READWRITE (O_RDWR | O_BINARY)
  47. #define FILEOPENERROR -1
  48. #define FILEOPEN(f,m) ibm_open(f, m, (((UWORD) m) == MODE_OLDFILE) ? S_IREAD : (S_IREAD | S_IWRITE))
  49. #define FILECLOSE(fd) ibm_close(fd)
  50. #define FILEREAD(f,b,n) ibm_read(f,b,(WORD)(n))
  51. #define FILEWRITE(f,b,n) ibm_write(f,b,(WORD)(n))
  52. #define FILESEEK(f,b,n) ibm_lseek(f, b, n)
  53. #define FILEDELETE(f) ibm_unlink(f)
  54. #define CHANGEDIR(p) ibm_chdir(p)
  55. #define FILENAMESIZE 13
  56. #define IO_CHUNK_SIZE 0xfff0UL
  57. /*
  58. ** Maximum number of file handles
  59. */
  60. #define TABLE_MAX 20
  61. /*=========================================================================*/
  62. /* The file handle table */
  63. /*=========================================================================*/
  64. typedef struct {
  65. BOOL Empty; // Is this handle empty?
  66. WORD Handle; // DOS file handle (0 = resident).
  67. LONG Pos; // Current file position.
  68. LONG Start; // Offset of file from pointer.
  69. WORD Index; // FileData[] index.
  70. WORD Mode; // Access mode (WW).
  71. BYTE *Name; // File name pointer.
  72. } FileHandleType;
  73. /*=========================================================================*/
  74. /* The following prototypes are for the file: FILEIO.CPP */
  75. /*=========================================================================*/
  76. WORD ibm_getdisk(VOID);
  77. WORD ibm_setdisk(WORD drive);
  78. WORD ibm_close(WORD handle);
  79. WORD ibm_unlink(BYTE const *name);
  80. LONG ibm_lseek(WORD handle, LONG offset, WORD where);
  81. UWORD ibm_read(WORD handle, VOID *ptr, UWORD bytes);
  82. UWORD ibm_write(WORD handle, VOID *ptr, UWORD bytes);
  83. WORD ibm_open(BYTE const *name, UWORD mode, WORD attrib);
  84. WORD ibm_chdir(BYTE const *path);
  85. /*=========================================================================*/
  86. /* The following prototypes are for the file: FILELIB.CPP */
  87. /*=========================================================================*/
  88. WORD cdecl Do_Open_Error(FileErrorType errormsgnum, BYTE const *file_name);
  89. VOID cdecl Do_IO_Error(FileErrorType errormsgnum, BYTE const *filename);
  90. LONG cdecl Read_File_With_Recovery( WORD handle, VOID *buf, UWORD bytes );
  91. WORD cdecl Open_File_With_Recovery( BYTE const *file_name, UWORD mode );
  92. BOOL cdecl Cache_File(WORD index, WORD file_handle);
  93. /*=========================================================================*/
  94. /* The following prototypes are for the file: DEVICES.ASM */
  95. /*=========================================================================*/
  96. #ifdef __cplusplus
  97. extern "C" {
  98. #endif
  99. extern VOID Get_Devices(VOID);
  100. extern WORD Is_Device_Real(WORD device);
  101. #ifdef __cplusplus
  102. }
  103. #endif
  104. /*=========================================================================*/
  105. /* The following prototypes are for the file: DEVTABLE.ASM */
  106. /*=========================================================================*/
  107. #ifdef __cplusplus
  108. extern "C" {
  109. #endif
  110. extern VOID Init_Device_Table(BYTE *table);
  111. extern WORD Max_Device(VOID);
  112. #ifdef __cplusplus
  113. }
  114. #endif
  115. /*=========================================================================*/
  116. /* The following prototypes are for the file: HARDERR.ASM */
  117. /*=========================================================================*/
  118. #ifdef __cplusplus
  119. extern "C" {
  120. #endif
  121. extern VOID Install_Hard_Error_Handler(VOID);
  122. extern VOID Remove_Hard_Error_Handler(VOID);
  123. #ifdef __cplusplus
  124. }
  125. #endif
  126. /*=========================================================================*/
  127. /* Globale variables in the fileio system. */
  128. /*=========================================================================*/
  129. extern BYTE CallingDOSInt;
  130. extern "C" extern BYTE MaxDevice,DefaultDrive;
  131. extern BYTE MultiDriveSearch;
  132. extern FileDataType *FileDataPtr;
  133. extern FileHandleType FileHandleTable[TABLE_MAX];
  134. extern UWORD NumFiles; // Number of files, except PAK, in file table.
  135. extern UWORD NumPAKFiles; // Number of PAK files in filetable.
  136. extern VOID *FileCacheHeap; // Pointer to the cache in memory.
  137. extern WORD DiskNumber;
  138. extern WORD MaxDirNum;
  139. /*=========================================================================*/
  140. #endif // _FILE_H