OSHost

OS host dependent procedures.

Const

INVALID_HANDLE* = API.INVALID_HANDLE_VALUE;
STDIN* = -10;
STDOUT* = -11;
STDERR* = -12;
DATETIMEOFFSET* = FALSE;

Types

HANDLE* = API.HANDLE;
DirEntry* = RECORD
        handle* : HANDLE;
        data*: API.WIN32_FIND_DATAA;
        first*: BOOLEAN;
    END;
DateTime* = RECORD
        year*, month*, day*, hour*, min*, sec*, msec*: INTEGER;
    END;

Procedures

ProgramNameLength

Get length of program name string

PROCEDURE ProgramNameLength*(): LENGTH;

ProgramName

Get program name

PROCEDURE ProgramName*(VAR name : ARRAY OF CHAR);

Args

Get number of program arguments

PROCEDURE Args*(): LENGTH;

ArgLength

Get length of argument string

PROCEDURE ArgLength*(n : LENGTH): LENGTH;

Arg

Get n-th argument

PROCEDURE Arg*(VAR str : ARRAY OF CHAR; n : LENGTH);

StdHandle

Open one of the standard streams STDING, STDOUT or STDERR. Return TRUE on success.

PROCEDURE StdHandle*(VAR handle : HANDLE; type : INTEGER): BOOLEAN;

FileOpen

Open new or existing file with mode flags. Return TRUE on success.

PROCEDURE FileOpen*(VAR handle : HANDLE; filename- : ARRAY OF CHAR; mode : SET): BOOLEAN;

FileClose

Close file. Return TRUE if success

PROCEDURE FileClose*(handle : HANDLE): BOOLEAN;

FileRead

Read from file into buffer. Return number of bytes actually read or -1 on failure.

PROCEDURE FileRead*(handle : HANDLE; buffer : ADDRESS; len : LENGTH): LENGTH;

FileWrite

Write from file into buffer. Return number of bytes actually written or -1 on failure.

PROCEDURE FileWrite*(handle : HANDLE; buffer : ADDRESS; len : LENGTH): LENGTH;

FileStdWrite

Write from std file into buffer. Return number of bytes actually written or -1 on failure.

PROCEDURE FileStdWrite*(handle : HANDLE; buffer : ADDRESS; len : LENGTH): LENGTH;

FileSeek

Set byte position in file. Return new position or -1 in case of failure.

PROCEDURE FileSeek*(handle : HANDLE; offset : LENGTH; mode : INTEGER): LENGTH;

FileTell

Return byte position in file or -1 on failure.

PROCEDURE FileTell*(handle : HANDLE): LENGTH;

FileSetSize

Set end of file to current position.

PROCEDURE FileSetSize*(handle : HANDLE): BOOLEAN;

FileTruncate

Truncate file to given size

PROCEDURE FileTruncate*(handle : HANDLE; size : LENGTH): LENGTH;

FileFlush

Flush buffered write operations to disk. Return TRUE on success.

PROCEDURE FileFlush*(handle : HANDLE): BOOLEAN;

FileExists

Check if file exists

PROCEDURE FileExists*(filename- : ARRAY OF CHAR): BOOLEAN;

FileRemove

Try to remove file. Return TRUE on success

PROCEDURE FileRemove*(filename- : ARRAY OF CHAR): BOOLEAN;

FileRename

Try to rename file. Return TRUE on success

PROCEDURE FileRename*(oldname-, newname-: ARRAY OF CHAR): BOOLEAN;

FileModificationTime

Try to get modification time for file. Return TRUE on success

PROCEDURE FileModificationTime*(VAR time : DateTime; filename-: ARRAY OF CHAR): BOOLEAN;

DirOpen

Open file/directory listing

PROCEDURE DirOpen*(VAR dir: DirEntry; name-: ARRAY OF CHAR);

DirClose

Close directory listing

PROCEDURE DirClose*(VAR dir: DirEntry);

DirNext

Return FALSE when end of file/directory listing is reached

PROCEDURE DirNext*(VAR dir: DirEntry): BOOLEAN;

DirNameLength

Return length of current directory listing name string

PROCEDURE DirNameLength*(VAR dir: DirEntry): LENGTH;

DirName

Return current directory listing name

PROCEDURE DirName*(dir-: DirEntry; VAR name: ARRAY OF CHAR);

DirIsDir

Return TRUE if current entry is a directory

PROCEDURE DirIsDir*(dir-: DirEntry): BOOLEAN;

GetTime

Get current local time

PROCEDURE GetTime*(VAR time : DateTime);

GetTimeZoneOffset

Get local time UTC offset

PROCEDURE GetTimeZoneOffset*(): INTEGER;

CDNameLength

Get string length of the current directory

PROCEDURE CDNameLength*(): LENGTH;

CDName

Get the current directory

PROCEDURE CDName*(VAR name: ARRAY OF CHAR; length: LENGTH);

SetCD

Get the current directory

PROCEDURE SetCD*(name-: ARRAY OF CHAR): BOOLEAN;

CreateDirectory

Try to create directory. Return TRUE on success

PROCEDURE CreateDirectory*(name-: ARRAY OF CHAR): BOOLEAN;

RemoveDirectory

Try to delete directory. Return TRUE on success

PROCEDURE RemoveDirectory*(name-: ARRAY OF CHAR): BOOLEAN;

EnvVarLength

Get string length of the environment variable

PROCEDURE EnvVarLength*(name-: ARRAY OF CHAR): LENGTH;

EnvVar

Get environment variable

PROCEDURE EnvVar*(VAR value: ARRAY OF CHAR; name-: ARRAY OF CHAR);

Exit

Exit with return code

PROCEDURE Exit*(code : INTEGER);

GetLastError

Get last error code or OK on no error.

PROCEDURE GetLastError*(VAR error: INTEGER);