StreamOpen:
PUBLIC
PROCEDURE [fileName:
ROPE, accessOptions: FS.AccessOptions, streamOptions: FS.StreamOptions, keep:
CARDINAL, createByteCount: FS.ByteCount, streamBufferParms: FS.StreamBufferParms, extendFileProc: FS.ExtendFileProc]
RETURNS [
STREAM] =
BEGIN
fileHandle: FS.OpenFile =
SELECT accessOptions
FROM
$read => FS.Open[name: fileName],
$create => FS.Create[name: fileName, keep: keep, pages: FS.PagesForBytes[createByteCount]],
$append => FS.OpenOrCreate[name: fileName, keep: keep, pages: FS.PagesForBytes[createByteCount]],
$write => FS.Open[name: fileName, lock: $write],
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]]];
END;
StreamFromOpenFile:
PUBLIC PROCEDURE [openFile: FS.OpenFile, accessRights: FS.Lock, initialPosition: FS.InitialPosition, streamOptions: FS.StreamOptions, streamBufferParms: FS.StreamBufferParms, extendFileProc: FS.ExtendFileProc]
RETURNS [
STREAM] =
BEGIN
RETURN [FileStream.StreamFromOpenFile[openFile: openFile, accessRights: accessRights, initialPosition: initialPosition, streamOptions: streamOptions, streamBufferParms: streamBufferParms, extendFileProc: extendFileProc]];
END;