82d72daa76
git-svn-id: svn://kolibrios.org@7597 a494cfbc-eb01-0410-851d-a64ba20cac60
120 lines
2.1 KiB
Plaintext
120 lines
2.1 KiB
Plaintext
(*
|
|
BSD 2-Clause License
|
|
|
|
Copyright (c) 2018, 2019, Anton Krotov
|
|
All rights reserved.
|
|
*)
|
|
|
|
MODULE UTILS;
|
|
|
|
IMPORT HOST, UNIXTIME;
|
|
|
|
|
|
CONST
|
|
|
|
slash* = HOST.slash;
|
|
|
|
bit_depth* = HOST.bit_depth;
|
|
maxint* = HOST.maxint;
|
|
minint* = HOST.minint;
|
|
|
|
OS = HOST.OS;
|
|
|
|
|
|
VAR
|
|
|
|
time*: INTEGER;
|
|
|
|
eol*: ARRAY 3 OF CHAR;
|
|
|
|
maxreal*: REAL;
|
|
|
|
|
|
PROCEDURE FileRead* (F: INTEGER; VAR Buffer: ARRAY OF BYTE; bytes: INTEGER): INTEGER;
|
|
RETURN HOST.FileRead(F, Buffer, bytes)
|
|
END FileRead;
|
|
|
|
|
|
PROCEDURE FileWrite* (F: INTEGER; Buffer: ARRAY OF BYTE; bytes: INTEGER): INTEGER;
|
|
RETURN HOST.FileWrite(F, Buffer, bytes)
|
|
END FileWrite;
|
|
|
|
|
|
PROCEDURE FileCreate* (FName: ARRAY OF CHAR): INTEGER;
|
|
RETURN HOST.FileCreate(FName)
|
|
END FileCreate;
|
|
|
|
|
|
PROCEDURE FileClose* (F: INTEGER);
|
|
BEGIN
|
|
HOST.FileClose(F)
|
|
END FileClose;
|
|
|
|
|
|
PROCEDURE FileOpen* (FName: ARRAY OF CHAR): INTEGER;
|
|
RETURN HOST.FileOpen(FName)
|
|
END FileOpen;
|
|
|
|
|
|
PROCEDURE GetArg* (i: INTEGER; VAR str: ARRAY OF CHAR);
|
|
BEGIN
|
|
HOST.GetArg(i, str)
|
|
END GetArg;
|
|
|
|
|
|
PROCEDURE Exit* (code: INTEGER);
|
|
BEGIN
|
|
HOST.ExitProcess(code)
|
|
END Exit;
|
|
|
|
|
|
PROCEDURE GetTickCount* (): INTEGER;
|
|
RETURN HOST.GetTickCount()
|
|
END GetTickCount;
|
|
|
|
|
|
PROCEDURE OutChar* (c: CHAR);
|
|
BEGIN
|
|
HOST.OutChar(c)
|
|
END OutChar;
|
|
|
|
|
|
PROCEDURE splitf* (x: REAL; VAR a, b: INTEGER): INTEGER;
|
|
RETURN HOST.splitf(x, a, b)
|
|
END splitf;
|
|
|
|
|
|
PROCEDURE isRelative* (path: ARRAY OF CHAR): BOOLEAN;
|
|
RETURN HOST.isRelative(path)
|
|
END isRelative;
|
|
|
|
|
|
PROCEDURE GetCurrentDirectory* (VAR path: ARRAY OF CHAR);
|
|
BEGIN
|
|
HOST.GetCurrentDirectory(path)
|
|
END GetCurrentDirectory;
|
|
|
|
|
|
PROCEDURE UnixTime* (): INTEGER;
|
|
VAR
|
|
year, month, day, hour, min, sec: INTEGER;
|
|
res: INTEGER;
|
|
|
|
BEGIN
|
|
IF OS = "LINUX" THEN
|
|
res := HOST.UnixTime()
|
|
ELSE
|
|
HOST.now(year, month, day, hour, min, sec);
|
|
res := UNIXTIME.time(year, month, day, hour, min, sec)
|
|
END
|
|
|
|
RETURN res
|
|
END UnixTime;
|
|
|
|
|
|
BEGIN
|
|
time := GetTickCount();
|
|
COPY(HOST.eol, eol);
|
|
maxreal := 1.9;
|
|
PACK(maxreal, 1023)
|
|
END UTILS. |