FSStreamImpl.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Taft, November 14, 1983 2:23 pm
Schroeder, November 28, 1983 12:35 pm
Bob Hagmann January 31, 1985 5:34:37 pm PST
Russ Atkinson (RRA) February 4, 1985 3:20:58 pm PST
Implementation of the "workstation FS" subclass of FileStream. This is mostly a veneer over the generic FileStream; only stream creation is special.
DIRECTORY
BasicTime USING [GMT],
FileStream USING [ErrorFromStream, OpenFileFromStream, StreamFromOpenFile, StreamFromOpenStream],
FS USING [AccessOptions, ByteCount, Close, Create, Error, ErrorDesc, ExtendFileProc, InitialPosition, Lock, Open, OpenFile, OpenOrCreate, PagesForBytes, StreamBufferParms, StreamOptions],
IO USING [STREAM],
Rope USING [ROPE];
FSStreamImpl:
CEDAR
PROGRAM
IMPORTS FileStream, FS
EXPORTS FS = { OPEN Rope, IO;
StreamOpen:
PUBLIC
PROC [fileName:
ROPE, accessOptions:
FS.AccessOptions,
streamOptions:
FS.StreamOptions, keep:
CARDINAL, createByteCount:
FS.ByteCount,
streamBufferParms:
FS.StreamBufferParms, extendFileProc:
FS.ExtendFileProc,
wantedCreatedTime: BasicTime.
GMT, remoteCheck:
BOOL, wDir:
ROPE]
RETURNS [
STREAM] = {
fileHandle:
FS.OpenFile =
SELECT accessOptions
FROM
$read => FS.Open[name: fileName, wantedCreatedTime: wantedCreatedTime, remoteCheck: remoteCheck, wDir: wDir],
$create => FS.Create[name: fileName, keep: keep, pages: FS.PagesForBytes[createByteCount], wDir: wDir],
$append => FS.OpenOrCreate[name: fileName, keep: keep, pages: FS.PagesForBytes[createByteCount], wDir: wDir],
$write => FS.Open[name: fileName, lock: $write, wantedCreatedTime: wantedCreatedTime, remoteCheck: remoteCheck, wDir: wDir],
ENDCASE => ERROR;
RETURN[FileStream.StreamFromOpenFile[openFile: fileHandle, accessRights:
IF accessOptions = $read
THEN $read
ELSE $write, initialPosition:
IF accessOptions = $append
THEN $end
ELSE $start, streamOptions: streamOptions, streamBufferParms: streamBufferParms, extendFileProc: extendFileProc
! FS.Error => FS.Close[file: fileHandle]]];
};
The following procedures simply re-export the ones from FileStream. However, directly exporting the procedure values imported from FileStream does not work for some reason.
StreamFromOpenFile:
PUBLIC
PROC [openFile:
FS.OpenFile, accessRights:
FS.Lock, initialPosition:
FS.InitialPosition, streamOptions:
FS.StreamOptions, streamBufferParms:
FS.StreamBufferParms, extendFileProc:
FS.ExtendFileProc]
RETURNS [
STREAM] = {
RETURN [FileStream.StreamFromOpenFile[openFile: openFile, accessRights: accessRights, initialPosition: initialPosition, streamOptions: streamOptions, streamBufferParms: streamBufferParms, extendFileProc: extendFileProc]];
};
StreamFromOpenStream:
PUBLIC
PROC [self:
STREAM]
RETURNS [
STREAM] = {
RETURN [FileStream.StreamFromOpenStream[self]];
};
OpenFileFromStream:
PUBLIC
PROC [self:
STREAM]
RETURNS [
FS.OpenFile] = {
RETURN [FileStream.OpenFileFromStream[self]];
};
ErrorFromStream:
PUBLIC
PROC [self:
STREAM]
RETURNS [
FS.ErrorDesc] = {
RETURN [FileStream.ErrorFromStream[self]];
};
}.
Bob Hagmann January 31, 1985 5:34:37 pm PST
Cedar 6.0: add more parameters for StreamOpen
changes to: StreamOpen, DIRECTORY