CnC_Remastered_Collection

Command and Conquer: Red Alert
Log | Files | Refs | README | LICENSE

FILE.H (9670B)


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