home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / pmos2002.zip / DEF / files.def < prev    next >
Text File  |  1997-05-08  |  3KB  |  83 lines

  1. DEFINITION MODULE Files;
  2.  
  3.         (****************************************************************)
  4.         (*                                                              *)
  5.         (*                      File operations                         *)
  6.         (*                                                              *)
  7.         (*      Note that the error code returned on an I/O             *)
  8.         (*      error is a rough guess, because of the lack of          *)
  9.         (*      correspondence between the library error codes and      *)
  10.         (*      the standard PMOS error codes.                          *)
  11.         (*                                                              *)
  12.         (*      Programmer:     P. Moylan                               *)
  13.         (*      Last edited:    8 May 1997                              *)
  14.         (*      Status:         Just starting ISO port                  *)
  15.         (*                                                              *)
  16.         (****************************************************************)
  17.  
  18. FROM SYSTEM IMPORT
  19.     (* type *)  BYTE, ADDRESS, CARD8;
  20.  
  21. FROM IOErrorCodes IMPORT
  22.     (* type *)  ErrorCode;
  23.  
  24. IMPORT RndFile;
  25.  
  26. TYPE File = RndFile.ChanId;
  27.  
  28. PROCEDURE OpenFile (VAR (*OUT*) f: File;  name: ARRAY OF CHAR;
  29.                                         newfile: BOOLEAN): ErrorCode;
  30.  
  31.     (* Opens the file named by the given character string, and returns  *)
  32.     (* f as the identification to be used when specifying this file in  *)
  33.     (* future.  The caller must specify newfile = TRUE to create a new  *)
  34.     (* file, or newfile = FALSE if the intention is to open an existing *)
  35.     (* file.  It is illegal to open a new file with the same name as an *)
  36.     (* existing file; this is to protect against accidental deletions.  *)
  37.     (* The value returned is an error code (OK if no error).            *)
  38.  
  39. PROCEDURE CloseFile (VAR (*INOUT*) f: File);
  40.  
  41.     (* Closes file f.   *)
  42.  
  43. PROCEDURE EOF (f: File): BOOLEAN;
  44.  
  45.     (* Returns TRUE iff we are currently at the end of file f.  *)
  46.  
  47. PROCEDURE ReadByte (f: File): CARD8;
  48.  
  49.     (* Returns the next byte from the file.     *)
  50.  
  51. PROCEDURE ReadRecord (f: File;  buffaddr: ADDRESS;  desired: CARDINAL;
  52.                                 VAR (*OUT*) actual: CARDINAL): ErrorCode;
  53.  
  54.     (* Reads up to "desired" bytes from file f to memory location       *)
  55.     (* "buffaddr".  On return, "actual" gives the number of bytes read. *)
  56.  
  57. PROCEDURE WriteByte (f: File;  value: BYTE): ErrorCode;
  58.  
  59.     (* Writes one byte to the file.     *)
  60.  
  61. PROCEDURE WriteRecord (f: File;  buffaddr: ADDRESS;
  62.                                         count: CARDINAL): ErrorCode;
  63.  
  64.     (* Writes count bytes from memory location buffaddr.        *)
  65.  
  66. PROCEDURE SetPosition (f: File;  position: CARDINAL): ErrorCode;
  67.  
  68.     (* Ensures that the next read or write on this file will be at      *)
  69.     (* byte number position in the file.  (The first byte in the file   *)
  70.     (* is byte number 0.)  If a position greater than the file size     *)
  71.     (* is specified, the length of the file will increase.              *)
  72.  
  73. PROCEDURE SavePosition (f: File): CARDINAL;
  74.  
  75.     (* Returns the current byte number in file f.       *)
  76.  
  77. PROCEDURE FileSize (f: File): CARDINAL;
  78.  
  79.     (* Returns the length of the file in bytes. *)
  80.  
  81. END Files.
  82.  
  83.