-- InterFile.mesa
-- written by Bill Paxton, May 1981
-- last edit by McGregor, June 10, 1982 4:43 pm
-- for reading and writing Tioga files in (pseudo) InterDoc format
DIRECTORY
File,
RopeEdit,
IO,
TextNode;
InterFile: CEDAR DEFINITIONS =
BEGIN
Ref: TYPE = TextNode.Ref;
ROPE: TYPE = RopeEdit.ROPE;
Offset: TYPE = TextNode.Offset;
MaxLen: Offset = LAST[Offset];
-- **** File Input/Output
ToFile: PROC [fileName: ROPE, node: Ref, start: Offset ← 0, flatten: BOOLEANTRUE]
RETURNS [count: Offset];
-- write the node on the specified file
-- starts writing at given address in file
-- returns the number of bytes written
FromFile: PROC [fileName: ROPE, start: Offset ← 0, len: Offset ← MaxLen] RETURNS [Ref];
-- create node from the contents of a file
-- starts reading at given start address in file
-- pretends that start+len is the end of the file
-- if file was not created by ToFile
-- then returns a single node containing contents of the file
FromFileError: ERROR;
-- **** Input/Output using ropes instead of files
ToRope: PROC [node: Ref, flatten: BOOLEANTRUE] RETURNS [ROPE];
-- resulting rope contains same representation of node as would be put on file
FromRope: PROC [rope: ROPE, start: Offset ← 0, len: Offset ← MaxLen] RETURNS [Ref];
-- reads rope to construct node
-- **** IO Operations ****
ToStream: PROC [stream: IO.Handle, node: Ref, flatten: BOOLEANTRUE]
RETURNS [count: Offset];
-- does a series of IO.PutBlock's
-- returns number of bytes written
FromStream: PROC [stream: IO.Handle, len: Offset ← MaxLen] RETURNS [Ref];
-- reads up to len chars from stream (via GetBlock's) to construct a node
-- ***** Initialization
StartPutFile: PROC;
StartGetFile: PROC;
END.