_FILE.H 6.6 KB

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