home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 19 / CD_ASCQ_19_010295.iso / dos / prg / midas / file.h < prev    next >
C/C++ Source or Header  |  1994-08-06  |  7KB  |  240 lines

  1. /*      FILE.H
  2.  *
  3.  * High-level file I/O for MIDAS Sound System
  4.  *
  5.  * Copyright 1994 Petteri Kangaslampi and Jarno Paananen
  6.  *
  7.  * This file is part of the MIDAS Sound System, and may only be
  8.  * used, modified and distributed under the terms of the MIDAS
  9.  * Sound System license, LICENSE.TXT. By continuing to use,
  10.  * modify or distribute this file you indicate that you have
  11.  * read the license and understand and accept it fully.
  12. */
  13.  
  14. #ifndef __FILE_H
  15. #define __FILE_H
  16.  
  17. #include "rawfile.h"
  18.  
  19.  
  20. /****************************************************************************\
  21. *       struct fileFile
  22. *       ---------------
  23. * Description:  File state structure
  24. \****************************************************************************/
  25.  
  26. typedef struct
  27. {
  28.     rfHandle    rf;
  29. } fileFile;
  30.  
  31.  
  32.  
  33.  
  34. /****************************************************************************\
  35. *       typedef fileHandle
  36. *       ------------------
  37. * Description: High-level file I/O file handle
  38. \****************************************************************************/
  39.  
  40. typedef fileFile* fileHandle;
  41.  
  42.  
  43.  
  44. /****************************************************************************\
  45. *       enum fileOpenMode
  46. *       -----------------
  47. * Description:  File opening mode. Used by fileOpen()
  48. \****************************************************************************/
  49.  
  50. enum fileOpenMode
  51. {
  52.     fileOpenRead = 1,                   /* open file for reading */
  53.     fileOpenWrite = 2,                  /* open file for writing */
  54.     fileOpenReadWrite = 3               /* open file for both reading and
  55.                                            writing */
  56. };
  57.  
  58.  
  59.  
  60. /****************************************************************************\
  61. *       enum fileSeekMode
  62. *       -----------------
  63. * Description:  File seeking mode. Used by fileSeek()
  64. \****************************************************************************/
  65.  
  66. enum fileSeekMode
  67. {
  68.     fileSeekAbsolute = 1,               /* seek to an absolute position from
  69.                                            the beginning of the file */
  70.     fileSeekRelative = 2,               /* seek to a position relative to
  71.                                            current position */
  72.     fileSeekEnd = 3                     /* seek relative to the end of file */
  73. };
  74.  
  75.  
  76.  
  77. #ifdef __cplusplus
  78. extern "C" {
  79. #endif
  80.  
  81.  
  82. /****************************************************************************\
  83. *
  84. * Function:     int fileOpen(char *fileName, int openMode, fileHandle *file);
  85. *
  86. * Description:  Opens a file for reading or writing
  87. *
  88. * Input:        char *fileName          name of file
  89. *               int openMode            file opening mode, see enum rfOpenMode
  90. *               fileHandle *file        pointer to file handle
  91. *
  92. * Returns:      MIDAS error code.
  93. *               File handle is stored in *file.
  94. *
  95. \****************************************************************************/
  96.  
  97. int CALLING fileOpen(char *fileName, int openMode, fileHandle *file);
  98.  
  99.  
  100.  
  101.  
  102. /****************************************************************************\
  103. *
  104. * Function:     int fileClose(fileHandle file);
  105. *
  106. * Description:  Closes a file opened with fileOpen().
  107. *
  108. * Input:        fileHandle file         handle of an open file
  109. *
  110. * Returns:      MIDAS error code
  111. *
  112. \****************************************************************************/
  113.  
  114. int CALLING fileClose(fileHandle file);
  115.  
  116.  
  117.  
  118.  
  119. /****************************************************************************\
  120. *
  121. * Function:     int fileGetSize(fileHandle file, long *fileSize);
  122. *
  123. * Description:  Get the size of a file
  124. *
  125. * Input:        fileHandle file         handle of an open file
  126. *               ulong *fileSize         pointer to file size
  127. *
  128. * Returns:      MIDAS error code.
  129. *               File size is stored in *fileSize.
  130. *
  131. \****************************************************************************/
  132.  
  133. int CALLING fileGetSize(fileHandle file, long *fileSize);
  134.  
  135.  
  136.  
  137.  
  138. /****************************************************************************\
  139. *
  140. * Function:     int fileRead(fileHandle file, void *buffer, ulong numBytes);
  141. *
  142. * Description:  Reads binary data from a file
  143. *
  144. * Input:        fileHandle file         file handle
  145. *               void *buffer            reading buffer
  146. *               ulong numBytes          number of bytes to read
  147. *
  148. * Returns:      MIDAS error code.
  149. *               Read data is stored in *buffer, which must be large enough
  150. *               for it.
  151. *
  152. \****************************************************************************/
  153.  
  154. int CALLING fileRead(fileHandle file, void *buffer, ulong numBytes);
  155.  
  156.  
  157.  
  158.  
  159. /****************************************************************************\
  160. *
  161. * Function:     int fileWrite(fileHandle file, void *buffer, ulong numBytes);
  162. *
  163. * Description:  Writes binary data to a file
  164. *
  165. * Input:        fileHandle file         file handle
  166. *               void *buffer            pointer to data to be written
  167. *               ulong numBytes          number of bytes to write
  168. *
  169. * Returns:      MIDAS error code
  170. *
  171. \****************************************************************************/
  172.  
  173. int CALLING fileWrite(fileHandle file, void *buffer, ulong numBytes);
  174.  
  175.  
  176.  
  177.  
  178. /****************************************************************************\
  179. *
  180. * Function:     int fileSeek(fileHandle file, long newPosition, int seekMode);
  181. *
  182. * Description:  Seeks to a new position in file. Subsequent reads and writes
  183. *               go to the new position.
  184. *
  185. * Input:        fileHandle file         file handle
  186. *               long newPosition        new file position
  187. *               int seekMode            file seek mode, see enum rfSeekMode
  188. *
  189. * Returns:      MIDAS error code
  190. *
  191. \****************************************************************************/
  192.  
  193. int CALLING fileSeek(fileHandle file, long newPosition, int seekMode);
  194.  
  195.  
  196.  
  197.  
  198. /****************************************************************************\
  199. *
  200. * Function:     int fileGetPosition(fileHandle file, long *position);
  201. *
  202. * Description:  Reads the current position in a file
  203. *
  204. * Input:        fileHandle file         file handle
  205. *               long *position          pointer to file position
  206. *
  207. * Returns:      MIDAS error code.
  208. *               Current file position is stored in *position.
  209. *
  210. \****************************************************************************/
  211.  
  212. int CALLING fileGetPosition(fileHandle file, long *position);
  213.  
  214.  
  215.  
  216. #ifdef __cplusplus
  217. }
  218. #endif
  219.  
  220.  
  221.  
  222. /****************************************************************************\
  223. *       enum fileFunctIDs
  224. *       -----------------
  225. * Description:  ID numbers for high-level file I/O functions
  226. \****************************************************************************/
  227.  
  228. enum fileFunctIDs
  229. {
  230.     ID_fileOpen = ID_file,
  231.     ID_fileClose,
  232.     ID_fileGetSize,
  233.     ID_fileRead,
  234.     ID_fileWrite,
  235.     ID_fileSeek,
  236.     ID_fileGetPosition
  237. };
  238.  
  239. #endif
  240.