Modula-2 Reloaded

A Modern Typesafe & Literate Programming Notation

Site Menu

Project

Specification

Implementation

Recommendations

Reference

Needs Updating

Work in Progress

Wastebasket

Wiki Manual

edit SideBar

Spec Raw IO

Raw IO

Spec.RawIO History

Hide minor edits - Show changes to output

2010-01-09 15:31 by benjk -
Changed lines 1-2 from:
DEFINITION MODULE RawIO;
to:
[@DEFINITION MODULE RawIO;
Changed lines 20-22 from:
     If the buffer is too small, data will be overwritten.
 
*)
to:
     If the buffer is too small, data will be overwritten. *)
Deleted line 24:
Changed line 40 from:
END RawIO.
to:
END RawIO.@]
2010-01-09 15:31 by benjk - imported from Rick's email of Jan 8, 2010
Added lines 1-42:
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.