RopeIO.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
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
Michael Plass, February 14, 1985 1:40:09 pm PST
This module provides efficient filing operations for ropes.
For reading, the files are copied to large buffers.
For writing, the characters from the ropes are block copied into large buffers for output.
DIRECTORY
FS USING [OpenFile],
IO USING [STREAM],
Rope USING [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.