Hardware manual

ksTypeReadOnly
ksTypeWriteOnly
ksTypeReadWrite
Its itemSize may be one of (see Streams.D for definitions):
charItem
wordItem
If you supply a cleanup routine, it will be called with the stream as parameter just before the stream is
destroyed by a Close. If returnOnCheckError is true, the routine will return 0 if the file id of the leader
page at the address specified in the file pointer is different from the file id in the file pointer. You would
want this if you wanted to use the file pointer as a hint, perhaps to be backed up by a directory lookup if it
fails. In fact, the standard directory routine OpenFile does exactly that. If you supply a zone, it will be
used to allocate the space needed by the stream. This space comes in two parts: the stream itself, about 60
words long, and the buffer, one page long.
Resets(s): flushes any buffers associated with the stream to the disk, and positions the stream to 0.
Closes(s): closes the stream, flushing the buffer and updating various information in the leader page if
necessary. The last things it does are to call the cleanup routine passed to CreateDiskStream, and then to
free the space for the stream. If the stream is open for writing only and it is not positioned at date byte 0,
the file length is truncated to the current position.
CleanupDiskStream(s): flushes any buffers associated with the stream to the disk.
3.2. Transferring Data
Gets(s): returns the next item (byte or word, depending on the item size), or causes an error if there are no
more items in the stream.
Puts(s, item): writes the next item into the stream. It causes an error if there is no more disk space, or if the
stream was created read-only.
ReadBlock(s, address, count) returns actualCount: reads count words from the stream into memory,
starting at the specified memory address. It returns the number of words actually read, which may be less
than count if there were not enough words in the file. It never causes an end-of-file error. It is possible to
use ReadBlock on a byte stream, but only if the stream is currently positioned at an even byte; otherwise
there will be an error.
WriteBlock(s, address, count): writes count words from memory into the stream, starting at the specified
memory address. The comment in ReadBlock about byte streams applies here also.
3.3. Reading state
Endofs(s): returns true if and only if there are no more items in the stream.
LnPageSize(s) returns the log (base 2) of the number of words in a page of the file.
FileLength(s, filePos []) returns lengthL: positions the file to its last byte and returns the length in bytes in
filePos (FPOS), and the length mod 2**16 as its value.
FilePos(s, filePos []) returns posL: returns the current byte position in filePos (FPOS), and the current
position mod 2**16 as its value.
GetCurrentFa(s, fileAddress) stores the current position in the file address (FA), including the disk address
of the current page as a hint which can be used by JumpToFa.
Disk Streams September 9, 1979 41
For Xerox Internal Use Only -- December 15, 1980