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 markup

2010-01-09 15:31 by benjk -
Changed lines 1-2 from:

DEFINITION MODULE Raw IO;

to:

[@DEFINITION MODULE Raw IO;

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 Raw IO.

to:

END Raw IO.@]

2010-01-09 15:31 by benjk - imported from Rick's email of Jan 8, 2010
Added lines 1-42:

DEFINITION MODULE Raw IO;

  (* 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.File Status?. *)

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 Read Byte? (fid: File; VAR to: SYSTEM.BYTE);

  (* Reads a storage units from cid, and assigns its value to "to". *)

PROCEDURE Read Bytes? (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 Read Word? (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 Write Byte?(fid : File; output : SYSTEM.BYTE);

  (* Writes the byte in 'output' to the file 'fid'. *)

PROCEDURE Write Word?(fid : File; output : SYSTEM.WORD);

 (* Writes the word in 'output' to the file 'fid'. *)

PROCEDURE Write Bytes?(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 Raw IO.