From Modula-2 Reloaded

Spec: Raw IO

DEFINITION MODULE RawIO;

  (* Reading and writing data over specified files using raw operations, i.e., with
      no conversion or interpretation. The file status is of the type File.FileStatus. *)

IMPORT File, SYSTEM;

(* The file status on reads is set to the value allRight, wrongFormat, or endOfInput. *)

PROCEDURE Read (fid: File; VAR to: ARRAY OF SYSTEM.BYTE);
  (* Reads storage units from cid, and assigns them to successive components of "to".
      The file status is set to the value allRight, wrongFormat, or endOfInput. *)

PROCEDURE ReadByte (fid: File; VAR to: SYSTEM.BYTE);
  (* Reads a storage units from cid, and assigns its value to "to". *)

PROCEDURE ReadBytes (fid : File; buffer : SYSTEM.ADDRESS; VAR length : CARDINAL);
  (* Reads 'length' bytes from the file 'fid' and stores them at 'buffer'.
     Actual number of bytes read returned in length
     If the buffer is too small, data will be overwritten. *)

PROCEDURE ReadWord (fid: File; VAR to: SYSTEM.WORD);
  (* Reads storage units from cid, and assigns their value to "to". The file status is set
      to the value allRight, wrongFormat, or endOfInput. *)

PROCEDURE Write (fid: File; from: ARRAY OF SYSTEM.BYTE);
  (* Writes storage units to cid from successive components of from. *)

PROCEDURE WriteByte(fid : File; output : SYSTEM.BYTE);
  (* Writes the byte in 'output' to the file 'fid'. *)

PROCEDURE WriteWord(fid : File; output : SYSTEM.WORD);
 (* Writes the word in 'output' to the file 'fid'. *)

PROCEDURE WriteBytes(fid : File; buffer : SYSTEM.ADDRESS; VAR length : CARDINAL);
  (* Writes the 'length' bytes starting at 'buffer' to the file 'fid'.
     Actual number of bytes read returned in length
     If the buffer is too small, undefined bytes will be written. *)

END RawIO.
Retrieved from http://modula-2.net/m2r10/pmwiki.php?n=Spec.RawIO
Page last modified on 2010-01-09 15:31