RopeIO.mesa
written by Bill Paxton, August 1982
Paxton, September 13, 1982 9:42 am
Maxwell, January 5, 1983 8:36 am
Russ Atkinson, July 21, 1983 7:39 pm
This module provides efficient filing operations for ropes.
For reading, the files are mapped in and block copied to large buffers.
For writing, the characters from the ropes are block copied into large buffers for output.
DIRECTORY
FS,
IO,
Rope;
RopeIO: CEDAR DEFINITIONS = BEGIN
ROPE: TYPE = Rope.ROPE;
ToFile: PROC [fileName, rope: ROPE, start: INT ← 0];
write the rope on the specified file
starts writing at given address in file
truncates file to end of rope
ToFileC: PROC [openFile: FS.OpenFile, rope: ROPE, start: INT ← 0];
like ToFile but uses openFile instead of file name (writes to new version, you betcha)
FromFile: PROC [fileName: ROPE, start: INT ← 0, len: INTLAST[INT]] RETURNS [ROPE];
create rope from the contents of a file
starts reading at given start address in file
pretends that start+len is the end of the file
FromFileC: PROC [openFile: FS.OpenFile, start: INT ← 0, len: INTLAST[INT]] RETURNS [ROPE];
like FromFile but uses openFile instead of file name
**** IO Stream Operations ****
PutRope: PROC [stream: IO.STREAM, rope: ROPE];
does a series of IO.PutBlock's
GetRope: PROC [stream: IO.STREAM, len: INTLAST[INT]] RETURNS [rope: ROPE];
reads up to len chars from stream (via GetBlock's) and makes a rope
END.