_FILE.H (6731B)
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 /*************************************************************************** 17 ;** 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 ** 18 ;*************************************************************************** 19 ;* * 20 ;* Project Name : Library - Filio header stuff. * 21 ;* * 22 ;* File Name : FILE.H * 23 ;* * 24 ;* Programmer : Scott K. Bowen * 25 ;* * 26 ;* Start Date : September 13, 1993 * 27 ;* * 28 ;* Last Update : April 11, 1994 * 29 ;* * 30 ;*-------------------------------------------------------------------------* 31 ;* Functions: * 32 ;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ 33 34 #ifndef FILE_H 35 #include "file.h" 36 #endif 37 38 #ifndef _FILE_H 39 #define _FILE_H 40 41 42 /*=========================================================================*/ 43 /* Fileio defines */ 44 /*=========================================================================*/ 45 46 #define LIB_CDROM TRUE 47 48 #define MODE_OLDFILE (O_RDONLY | O_BINARY) 49 #define MODE_NEWFILE (O_WRONLY | O_BINARY | O_CREAT | O_TRUNC) 50 #define MODE_READWRITE (O_RDWR | O_BINARY) 51 52 #define FILEOPENERROR -1 53 #define FILEOPEN(f,m) ibm_open(f, m, (((UWORD) m) == MODE_OLDFILE) ? S_IREAD : (S_IREAD | S_IWRITE)) 54 55 #define FILECLOSE(fd) ibm_close(fd) 56 #define FILEREAD(f,b,n) ibm_read(f,b,(WORD)(n)) 57 #define FILEWRITE(f,b,n) ibm_write(f,b,(WORD)(n)) 58 #define FILESEEK(f,b,n) ibm_lseek(f, b, n) 59 #define FILEDELETE(f) ibm_unlink(f) 60 #define CHANGEDIR(p) ibm_chdir(p) 61 62 #define FILENAMESIZE 13 63 #define IO_CHUNK_SIZE 0xfff0UL 64 65 /* 66 ** Maximum number of file handles 67 */ 68 #define TABLE_MAX 20 69 70 71 /*=========================================================================*/ 72 /* The file handle table */ 73 /*=========================================================================*/ 74 typedef struct { 75 BOOL Empty; // Is this handle empty? 76 WORD Handle; // DOS file handle (0 = resident). 77 LONG Pos; // Current file position. 78 LONG Start; // Offset of file from pointer. 79 WORD Index; // FileData[] index. 80 WORD Mode; // Access mode (WW). 81 BYTE *Name; // File name pointer. 82 } FileHandleType; 83 84 85 /*=========================================================================*/ 86 /* The following prototypes are for the file: FILEIO.CPP */ 87 /*=========================================================================*/ 88 89 WORD ibm_getdisk(VOID); 90 WORD ibm_setdisk(WORD drive); 91 WORD ibm_close(WORD handle); 92 WORD ibm_unlink(BYTE const *name); 93 LONG ibm_lseek(WORD handle, LONG offset, WORD where); 94 UWORD ibm_read(WORD handle, VOID *ptr, UWORD bytes); 95 UWORD ibm_write(WORD handle, VOID *ptr, UWORD bytes); 96 WORD ibm_open(BYTE const *name, UWORD mode, WORD attrib); 97 WORD ibm_chdir(BYTE const *path); 98 99 /*=========================================================================*/ 100 /* The following prototypes are for the file: FILELIB.CPP */ 101 /*=========================================================================*/ 102 103 WORD cdecl Do_Open_Error(FileErrorType errormsgnum, BYTE const *file_name); 104 VOID cdecl Do_IO_Error(FileErrorType errormsgnum, BYTE const *filename); 105 LONG cdecl Read_File_With_Recovery( WORD handle, VOID *buf, UWORD bytes ); 106 WORD cdecl Open_File_With_Recovery( BYTE const *file_name, UWORD mode ); 107 BOOL cdecl Cache_File(WORD index, WORD file_handle); 108 109 110 /*=========================================================================*/ 111 /* The following prototypes are for the file: DEVICES.ASM */ 112 /*=========================================================================*/ 113 114 #ifdef __cplusplus 115 extern "C" { 116 #endif 117 118 extern VOID Get_Devices(VOID); 119 extern WORD Is_Device_Real(WORD device); 120 121 #ifdef __cplusplus 122 } 123 #endif 124 125 /*=========================================================================*/ 126 /* The following prototypes are for the file: DEVTABLE.ASM */ 127 /*=========================================================================*/ 128 129 #ifdef __cplusplus 130 extern "C" { 131 #endif 132 133 extern VOID Init_Device_Table(BYTE *table); 134 extern WORD Max_Device(VOID); 135 136 137 #ifdef __cplusplus 138 } 139 #endif 140 141 142 /*=========================================================================*/ 143 /* The following prototypes are for the file: HARDERR.ASM */ 144 /*=========================================================================*/ 145 146 #ifdef __cplusplus 147 extern "C" { 148 #endif 149 150 extern VOID Install_Hard_Error_Handler(VOID); 151 extern VOID Remove_Hard_Error_Handler(VOID); 152 153 #ifdef __cplusplus 154 } 155 #endif 156 157 158 /*=========================================================================*/ 159 /* Globale variables in the fileio system. */ 160 /*=========================================================================*/ 161 162 extern BYTE CallingDOSInt; 163 extern "C" extern BYTE MaxDevice,DefaultDrive; 164 extern BYTE MultiDriveSearch; 165 extern FileDataType *FileDataPtr; 166 extern FileHandleType FileHandleTable[TABLE_MAX]; 167 extern UWORD NumFiles; // Number of files, except PAK, in file table. 168 extern UWORD NumPAKFiles; // Number of PAK files in filetable. 169 extern VOID *FileCacheHeap; // Pointer to the cache in memory. 170 extern WORD DiskNumber; 171 extern WORD MaxDirNum; 172 173 174 /*=========================================================================*/ 175 176 177 178 #endif // _FILE_H 179 180