FILEIO.CPP 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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 : Westwood Library *
  23. * *
  24. * File Name : FILEIO.C *
  25. * *
  26. * Programmer : Joe L. Bostic *
  27. * *
  28. * Start Date : August 21, 1991 *
  29. * *
  30. * Last Update : September 13, 1993 [SKB] *
  31. * *
  32. *-------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #ifndef WWSTD_H
  36. #include "wwstd.h"
  37. #endif
  38. #ifndef _FILE_H
  39. #include "_file.h"
  40. #endif
  41. #include <dos.h>
  42. #include <direct.h>
  43. #include <io.h>
  44. /*=========================================================================*/
  45. /* The following PRIVATE functions are in this file: */
  46. /*=========================================================================*/
  47. /*= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
  48. WORD ibm_getdisk(VOID)
  49. {
  50. unsigned disk;
  51. CallingDOSInt++;
  52. // disk = getdisk();
  53. _dos_getdrive ( & disk ) ;
  54. CallingDOSInt--;
  55. return(disk-1);
  56. }
  57. WORD ibm_setdisk(WORD drive)
  58. {
  59. // WORD disk;
  60. unsigned disk ;
  61. CallingDOSInt++;
  62. // disk = setdisk(drive);
  63. _dos_setdrive ( drive+1 , & disk ) ;
  64. CallingDOSInt--;
  65. return(disk);
  66. }
  67. WORD ibm_close(WORD handle)
  68. {
  69. WORD success;
  70. CallingDOSInt++;
  71. success = close(handle);
  72. CallingDOSInt--;
  73. return(success);
  74. }
  75. WORD ibm_unlink(BYTE const *name)
  76. {
  77. WORD success;
  78. CallingDOSInt++;
  79. success = unlink(name);
  80. CallingDOSInt--;
  81. return(success);
  82. }
  83. LONG ibm_lseek(WORD handle, LONG offset, WORD where)
  84. {
  85. LONG new_offset;
  86. CallingDOSInt++;
  87. new_offset = lseek(handle, offset, where);
  88. CallingDOSInt--;
  89. return(new_offset);
  90. }
  91. UWORD ibm_read(WORD handle, VOID *ptr, UWORD bytes)
  92. {
  93. UWORD bytes_read;
  94. CallingDOSInt++;
  95. bytes_read = read(handle, ptr, bytes);
  96. CallingDOSInt--;
  97. return(bytes_read);
  98. }
  99. UWORD ibm_write(WORD handle, VOID *ptr, UWORD bytes)
  100. {
  101. UWORD bytes_written;
  102. CallingDOSInt++;
  103. bytes_written = write(handle, ptr, bytes);
  104. CallingDOSInt--;
  105. return(bytes_written);
  106. }
  107. WORD ibm_open(BYTE const *name, UWORD mode, WORD attrib)
  108. {
  109. WORD handle;
  110. CallingDOSInt++;
  111. handle = open(name, mode, attrib);
  112. CallingDOSInt--;
  113. return(handle);
  114. }
  115. WORD ibm_chdir(BYTE const *path)
  116. {
  117. WORD retval;
  118. CallingDOSInt++;
  119. retval = chdir(path);
  120. CallingDOSInt--;
  121. return(retval);
  122. }
  123.