Oberon || Library || Module Index || Search Engine || Definition || Module
CONST read = 0; write = 1; rdwr = 2; TYPE Mode = SHORTINT; (* read..rdwr *)
CONST beyondEndOfStream = 0; CONST posOutOfRange = 1; CONST invalidRange = 2; CONST errors = 3; TYPE ErrorCode = SHORTINT; (* illegalMode..beyondEndOfStream *) TYPE ErrorEvent = POINTER TO ErrorEventRec; TYPE ErrorEventRec = RECORD (Events.EventRec) errorcode: ErrorCode; END; VAR error: Events.EventType; VAR errormsg: ARRAY errors OF Events.Message;
PROCEDURE Open(VAR s: Streams.Stream; addr: Types.Address; length: Types.Size; mode: Mode);
PROCEDURE OpenU(VAR s: Streams.Stream; addr: Types.UntracedAddress; length: Types.Size; mode: Mode);
MemStreams may be particularly useful for other stream implementations which keep their stream contents in-memory in a contiguous buffer as substream implementation (see SubStreams). MemStreams itself supports SubStreams as well.
It is in the responsibility of the stream creator to assure that the validity of the memory area is associated with the validity of the stream, i.e. if the memory area should become deallocated (no matter by which method), the stream should terminate (see Resources). Note that this link will be established automatically if MemStreams is used as a substream implementation (see SubStreams and Forwarders).
Besides the read and write operations, seek and tell, also trunc operations are permitted which allow to reduce the length of the stream.
Note that passing an invalid mode to Open or OpenU will result in a runtime error.
Oberon || Library || Module Index || Search Engine || Definition || Module