MimSysOps.mesa
Copyright Ó 1987, 1988, 1991 by Xerox Corporation. All rights reserved.
Russ Atkinson (RRA) December 12, 1988 3:47:55 pm PST
DIRECTORY
BasicTime USING [GMT],
IO USING [STREAM],
Rope USING [ROPE];
MimSysOps: CEDAR DEFINITIONS = BEGIN OPEN BasicTime, IO, Rope;
Interceptor: TYPE = REF InterceptorRecord;
InterceptorRecord: TYPE = RECORD [
open: OpenProc,
close: CloseProc,
delete: DeleteProc,
data: REF ¬ NIL
];
OpenProc: TYPE = PROC
[interceptor: Interceptor, name: ROPE, kind: OpenKind]
RETURNS [stream: STREAM, err: ROPE, time: GMT];
OpenKind: TYPE = {read, write, writeLog};
Opens the named file and returns a stream to it. If the stream cannot be opened then an error message is returned.
CloseProc: TYPE = PROC
[interceptor: Interceptor, stream: STREAM, abortAndDelete: BOOL]
RETURNS [err: ROPE];
Closes the given stream. If abortAndDelete, then abort all output operations and delete the associated file (if any). Otherwise, normal close is performed.
DeleteProc: TYPE = PROC
[interceptor: Interceptor, name: ROPE]
RETURNS [err: ROPE];
Deletes the named file (returning a messge if not possible).
Intercept: PROC [interceptor: Interceptor] RETURNS [old: Interceptor];
Intercepts the system operations, returning the previous interceptor (if any).
Open: PROC [name: ROPE, kind: OpenKind]
RETURNS [stream: STREAM, err: ROPE, time: BasicTime.GMT];
Opens the file via the current interceptor proc.
Close: PROC [stream: STREAM, abortAndDelete: BOOL ¬ FALSE] RETURNS [err: ROPE];
Closes the stream via the current interceptor proc. If abortAndDelete, then all I/O operations on files opened with kind in {read, write} will be aborted, and all files opened with kind = write will be deleted.
Delete: PROC [name: ROPE] RETURNS [err: ROPE];
Deletes the named file (returning a messge if not possible).
Cleanup: PROC [abortAndDelete: BOOL];
Closes all open streams managed by MimSysOps.
MappedFile: TYPE = REF MappedFileRecord;
MappedFileRecord: TYPE;
Map: PROC [name: ROPE] RETURNS [mf: MappedFile, err: ROPE];
Opens the named file and maps it into memory, returning a MappedFile object if the opeinging was successful, and an error message if the opening was not successful.
UnMap: PROC [mf: MappedFile];
Unmaps the file. The memory will not necessarily become invalid, but the user should not continue to use it.
MapBase: PROC [mf: MappedFile] RETURNS [LONG POINTER];
Returns the address of the first word in the memory for the mapped file. NIL is returned for invaid mapped files.
MapLength: PROC [mf: MappedFile] RETURNS [CARD];
Returns the # of bytes in the mapped file.
END.