OSStream
Module for Stream class with access to OS files and the standard streams.
Const
INVALID_HANDLE* = OSHost.INVALID_HANDLE;
STDIN* = OSHost.STDIN;
STDOUT* = OSHost.STDOUT;
STDERR* = OSHost.STDERR;
AccessRead* = Const.AccessRead;
AccessWrite* = Const.AccessWrite;
ModeNew* = Const.ModeNew;
SeekSet* = Const.SeekSet;
SeekCur* = Const.SeekCur;
SeekEnd* = Const.SeekEnd;
OK* = Const.OK;
Types
File* = RECORD(ADTStream.ADTStream)
fh : OSHost.HANDLE;
mode : SET;
opened : BOOLEAN;
END;
Std* = RECORD(ADTStream.ADTStream)
fh : OSHost.HANDLE;
type : INTEGER;
END;
Vars
StdErr* : Std;
StdErr* : Std;
StdErr* : Std;
Procedures
File.Open
Open a OS file with given mode. Return TRUE on success.
PROCEDURE (VAR s : File) Open*(filename- : ARRAY OF CHAR; mode: SET): BOOLEAN;
File.Close
Close Stream
PROCEDURE (VAR s : File) Close*();
File.Closed
Return TRUE if Stream is closed
PROCEDURE (VAR s : File) Closed*(): BOOLEAN;
File.ReadBytes
Read bytes into buffer with start and length.
PROCEDURE (VAR s : File) ReadBytes*(VAR buffer : ARRAY OF BYTE; start, length : LENGTH): LENGTH;
File.WriteBytes
Write bytes from buffer with start and length.
PROCEDURE (VAR s : File) WriteBytes*(VAR buffer : ARRAY OF BYTE; start, length : LENGTH): LENGTH;
File.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 (VAR s : File) Seek*(offset : LENGTH; mode : INTEGER): LENGTH;
File.Tell
Return current position or -1 on failure.
PROCEDURE (VAR s : File) Tell*(): LENGTH;
File.Truncate
Truncates or extends stream to new size. Return new size or -1 in case of failure.
PROCEDURE (VAR s : File) Truncate*(size : LENGTH): LENGTH;
File.Flush
Flush buffers
PROCEDURE (VAR s : File) Flush*();
File.Readable
Return TRUE if Stream is readable
PROCEDURE (VAR s : File) Readable*(): BOOLEAN;
File.Writeable
Return TRUE if Stream is writeable
PROCEDURE (VAR s : File) Writeable*(): BOOLEAN;
File.Seekable
Return TRUE if Stream is seekable
PROCEDURE (VAR s : File) Seekable*(): BOOLEAN;
Std.Open
Open one of the standard streams STDING, STDOUT or STDERR. Return TRUE on success.
PROCEDURE (VAR s : Std) Open*(type : INTEGER): BOOLEAN;
Std.Close
Close Stream
PROCEDURE (VAR s : Std) Close*();
Std.Check
Check if we need to open Stream variables
PROCEDURE (VAR s : Std) Check*();
Std.ReadBytes
Read bytes into buffer with start and length.
PROCEDURE (VAR s : Std) ReadBytes*(VAR buffer : ARRAY OF BYTE; start, length : LENGTH): LENGTH;
Std.WriteBytes
Write bytes from buffer with start and length.
PROCEDURE (VAR s : Std) WriteBytes*(VAR buffer : ARRAY OF BYTE; start, length : LENGTH): LENGTH;
Std.IsTTY
Return TRUE if Stream is a TTY
PROCEDURE (VAR s : Std) IsTTY*(): BOOLEAN;
Std.Readable
Return TRUE if Stream is readable
PROCEDURE (VAR s : Std) Readable*(): BOOLEAN;
Std.Writeable
Return TRUE if Stream is writeable
PROCEDURE (VAR s : Std) Writeable*(): BOOLEAN;
Std.Seekable
Return TRUE if Stream is seekable
PROCEDURE (VAR s : Std) Seekable*(): BOOLEAN;