PutGet.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
written by Bill Paxton, May 1981
last edit by Paxton. October 21, 1982 1:55 pm
Russ Atkinson, July 22, 1983 10:24 am
Doug Wyatt, March 2, 1985 4:41:37 pm PST
File Input/Output
ToFile: PROC [fileName: ROPE, node: Ref, start: INT ← 0, flatten, textOnly: BOOL ← FALSE]
RETURNS [dataLen, count: INT];
ToFileC:
PROC [file:
FS.OpenFile, node: Ref, start:
INT ← 0, flatten, textOnly:
BOOL ←
FALSE]
RETURNS [dataLen, count:
INT];
write the node on the specified file
starts writing at given address in file
returns dataLen = number of data bytes at start of file,
and count = the total number of bytes written
FromFile: PROC [fileName: ROPE, start: INT ← 0, len: INT ← MaxLen] RETURNS [Ref];
FromFileC:
PROC [file:
FS.OpenFile, start:
INT ← 0, len:
INT ← 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 (i.e., password not correct)
then returns a single node containing contents of the file
WritePlain: PROC[h: IO.STREAM, root: Ref, restoreDashes: BOOL ← FALSE];
WriteFilePlain: PROC [fileName: ROPE, root: Ref];
WriteFileCPlain:
PROC [file:
FS.OpenFile, root: Ref];
gives text of file with CR after each node and TABs before according to nesting
WriteMesaFilePlain:
PROC [fileName:
ROPE, root: Ref];
like WriteFilePlain, but adds initial dashes to comments if necessary.
Input/Output using ropes instead of files
ToRope:
PROC [node: Ref, flatten, textOnly:
BOOL ←
FALSE]
RETURNS [dataLen, count:
INT, output:
ROPE];
resulting rope contains same representation of node as would be put on file
FromRope:
PROC [rope:
ROPE, start:
INT ← 0, len:
INT ← MaxLen]
RETURNS [Ref];
reads rope to construct node
WriteRopePlain:
PROC [root: Ref, restoreDashes:
BOOL ←
FALSE]
RETURNS [output:
ROPE];
IO Operations
ToStream:
PROC [stream:
IO.
STREAM, node: Ref, flatten, textOnly:
BOOL ←
FALSE]
RETURNS [dataLen, count:
INT];
does a series of IO.PutBlock's
returns number of bytes written
FromStream:
PROC [stream:
IO.
STREAM, len:
INT ← MaxLen]
RETURNS [Ref];
reads up to len chars from stream (via GetBlock's) to construct a node