OSStream
Module for Stream class with access to OS files and the standard streams.
The standard streams stdin, stdout and stderr are accessable as variables exported from this module and is opened on demand.
Reference Object module for further details on procedures/functions.
Const
ModeRead* = xlibOS.X2C_fAccessRead;
ModeWrite* = xlibOS.X2C_fAccessWrite;
ModeNew* = xlibOS.X2C_fModeNew;
ModeText* = xlibOS.X2C_fModeText;
ModeRaw* = xlibOS.X2C_fModeRaw;
SeekSet* = Object.SeekSet;
SeekCur* = Object.SeekCur;
SeekEnd* = Object.SeekEnd;
StreamOK* = Object.StreamOK;
StreamNotImplementedError* = Object.StreamNotImplementedError;
StreamNotOpenError* = Object.StreamNotOpenError;
StreamReadError* = Object.StreamReadError;
StreamWriteError* = Object.StreamWriteError;
Types
StreamDesc* = Object.StreamDesc;
StreamFile* = POINTER TO StreamFileDesc;
StreamFileDesc* = RECORD (StreamDesc)
fh : xlibOS.X2C_OSFHANDLE;
mode : SET;
opened : BOOLEAN;
END;
StreamStdIn* = POINTER TO StreamStdInDesc;
StreamStdInDesc* = RECORD (StreamDesc)
fh : xlibOS.X2C_OSFHANDLE;
opened : BOOLEAN;
END;
StreamStdOut* = POINTER TO StreamStdOutDesc;
StreamStdOutDesc* = RECORD (StreamDesc)
fh : xlibOS.X2C_OSFHANDLE;
opened : BOOLEAN;
END;
StreamStdErr* = POINTER TO StreamStdErrDesc;
StreamStdErrDesc* = RECORD (StreamDesc)
fh : xlibOS.X2C_OSFHANDLE;
opened : BOOLEAN;
END;
Procedures
StreamFile.Open
Open a OS file with given mode (defaults to ModeRead + ModeRaw). Return TRUE on success.
PROCEDURE (s : StreamFile) Open*(filename- : ARRAY OF CHAR; mode := ModeRead + ModeRaw: SET): BOOLEAN;
StreamFile.Format
Writes formatted string according to fmt definition and arguments. Reference Format module for further details. Sets error to StreamWriteError on failure.
PROCEDURE (s : StreamFile) Format*(fmt- : ARRAY OF CHAR; SEQ seq: SYSTEM.BYTE);
StreamFile.FormatInteger
Writes formatted string from LONGLONGINT value. This is a separate procedure for handling 64bit values due to a limitation in the XDS compiler. Reference Format module for further details. Sets error to StreamWriteError on failure.
PROCEDURE (s : StreamFile) FormatInteger*(value : LONGLONGINT; width := 0 : LONGINT; flags := {} : SET);
StreamFile.FormatCardinal
Writes formatted string from CARD64 value. This is a separate procedure for handling 64bit values due to a limitation in the XDS compiler. Reference Format module for further details. Sets error to StreamWriteError on failure.
PROCEDURE (s : StreamFile) FormatCardinal*(value : SYSTEM.CARD64; base := 10 : INTEGER; width := 0 : LONGINT; flags := {} : SET);
StreamFile.ReadBytes
Read bytes into buffer with optional start and length.
PROCEDURE (s : StreamFile) ReadBytes*(VAR buffer : ARRAY OF BYTE; start := 0 : LONGINT; length := - 1 : LONGINT): LONGINT;
StreamFile.WriteBytes
Write bytes from buffer with optional start and length.
PROCEDURE (s : StreamFile) WriteBytes*(buffer- : ARRAY OF BYTE; start := 0 : LONGINT; length := - 1 : LONGINT): LONGINT;
StreamFile.Seek
Offsets or set the current location depending on the mode argument:
SeekSet : sets position relative to start of stream.
SeekCur : sets position relative to current position of stream.
SeekEnd : sets position relative to end position of stream (only negative offset values makes sense).
Return new position or -1 in case of failure.
PROCEDURE (s : StreamFile) Seek*(offset : LONGINT; mode := SeekSet : INTEGER): LONGINT;
StreamFile.Tell
Return current position or -1 on failure.
PROCEDURE (s : StreamFile) Tell*(): LONGINT;
StreamFile.Truncate
Truncates or extends stream to new size. Return new size or -1 in case of failure.
PROCEDURE (s : StreamFile) Truncate*(size : LONGINT): LONGINT;
StreamFile.Flush
Flush buffers
PROCEDURE (s : StreamFile) Flush*();
StreamFile.Close
Close Stream
PROCEDURE (s : StreamFile) Close*();
StreamFile.Closed
Return TRUE if Stream is closed
PROCEDURE (s : StreamFile) Closed*(): BOOLEAN;
StreamFile.Readable
Return TRUE if Stream is readable
PROCEDURE (s : StreamFile) Readable*(): BOOLEAN;
StreamFile.Writeable
Return TRUE if Stream is writeable
PROCEDURE (s : StreamFile) Writeable*(): BOOLEAN;
StreamFile.Seekable
Return TRUE if Stream is seekable
PROCEDURE (s : StreamFile) Seekable*(): BOOLEAN;
StreamStdIn.ReadBytes
Read bytes into buffer with optional start and length.
PROCEDURE (s : StreamStdIn) ReadBytes*(VAR buffer : ARRAY OF BYTE; start := 0 : LONGINT; length := - 1 : LONGINT): LONGINT;
StreamStdIn.ReadChar
Read CHAR value. Return TRUE if success.
PROCEDURE (s : StreamStdIn) ReadChar*(VAR value : CHAR): BOOLEAN;
StreamStdIn.Readable
Return TRUE if Stream is readable
PROCEDURE (s : StreamStdIn) Readable*(): BOOLEAN;
StreamStdIn.IsTTY
Return TRUE if Stream is a TTY
PROCEDURE (s : StreamStdIn) IsTTY*(): BOOLEAN;
StreamStdOut.Format
Writes formatted string according to fmt definition and arguments. Reference Format module for further details. Sets error to StreamWriteError on failure.
PROCEDURE (s : StreamStdOut) Format*(fmt- : ARRAY OF CHAR; SEQ seq: SYSTEM.BYTE);
StreamStdOut.FormatInteger
Writes formatted string from LONGLONGINT value. This is a separate procedure for handling 64bit values due to a limitation in the XDS compiler. Reference Format module for further details. Sets error to StreamWriteError on failure.
PROCEDURE (s : StreamStdOut) FormatInteger*(value : LONGLONGINT; width := 0 : LONGINT; flags := {} : SET);
StreamStdOut.FormatCardinal
Writes formatted string from CARD64 value. This is a separate procedure for handling 64bit values due to a limitation in the XDS compiler. Reference Format module for further details. Sets error to StreamWriteError on failure.
PROCEDURE (s : StreamStdOut) FormatCardinal*(value : SYSTEM.CARD64; base := 10 : INTEGER; width := 0 : LONGINT; flags := {} : SET);
StreamStdOut.WriteBytes
Write bytes from buffer with optional start and length.
PROCEDURE (s : StreamStdOut) WriteBytes*(buffer- : ARRAY OF BYTE; start := 0 : LONGINT; length := - 1 : LONGINT): LONGINT;
StreamStdOut.Writeable
Return TRUE if Stream is writeable
PROCEDURE (s : StreamStdOut) Writeable*(): BOOLEAN;
StreamStdOut.IsTTY
Return TRUE if Stream is a TTY
PROCEDURE (s : StreamStdOut) IsTTY*(): BOOLEAN;
StreamStdErr.Format
Writes formatted string according to fmt definition and arguments. Reference Format module for further details. Sets error to StreamWriteError on failure.
PROCEDURE (s : StreamStdErr) Format*(fmt- : ARRAY OF CHAR; SEQ seq: SYSTEM.BYTE);
StreamStdErr.FormatInteger
Writes formatted string from LONGLONGINT value. This is a separate procedure for handling 64bit values due to a limitation in the XDS compiler. Reference Format module for further details. Sets error to StreamWriteError on failure.
PROCEDURE (s : StreamStdErr) FormatInteger*(value : LONGLONGINT; width := 0 : LONGINT; flags := {} : SET);
StreamStdErr.FormatCardinal
Writes formatted string from CARD64 value. This is a separate procedure for handling 64bit values due to a limitation in the XDS compiler. Reference Format module for further details. Sets error to StreamWriteError on failure.
PROCEDURE (s : StreamStdErr) FormatCardinal*(value : SYSTEM.CARD64; base := 10 : INTEGER; width := 0 : LONGINT; flags := {} : SET);
StreamStdErr.WriteBytes
Write bytes from buffer with optional start and length.
PROCEDURE (s : StreamStdErr) WriteBytes*(buffer- : ARRAY OF BYTE; start := 0 : LONGINT; length := - 1 : LONGINT): LONGINT;
StreamStdErr.Writeable
Return TRUE if Stream is writeable
PROCEDURE (s : StreamStdErr) Writeable*(): BOOLEAN;
StreamStdErr.IsTTY
Return TRUE if Stream is a TTY
PROCEDURE (s : StreamStdErr) IsTTY*(): BOOLEAN;