CRT functions/procedures made safe with overloaded Write/WriteLn implementations

This commit is contained in:
2020-06-09 03:30:39 +03:00
parent 023d565b81
commit 6ee928a133
6 changed files with 208 additions and 57 deletions

View File

@@ -19,8 +19,8 @@ begin
repeat
with GetSystemDate, GetSystemTime do
begin
Write('%02x.%02x.%02x', Day, Month, Year);
Write(' - %02x:%02x:%02x', Hours, Minutes, Seconds);
Write('%02x.%02x.%02x', [Day, Month, Year]);
Write(' - %02x:%02x:%02x', [Hours, Minutes, Seconds]);
end;
GotoXY(CursorXY);
Delay(500);

View File

@@ -10,14 +10,14 @@ const
BUFFER_SIZE = 256;
var
Buffer: array[0..BUFFER_SIZE - 1] of Char;
Buffer: array[0..BUFFER_SIZE - 1] of KolibriChar;
begin
InitConsole('Get Current Directory', False);
GetCurrentDirectory(Buffer, BUFFER_SIZE);
Write('AppPath is "%s"'#10, AppPath^);
Write('CmdLine is "%s"'#10, CmdLine^);
Write('Current Directory is "%s"'#10, Buffer);
WriteLn('AppPath is "%s"', [AppPath^]);
WriteLn('CmdLine is "%s"', [CmdLine^]);
WriteLn('Current Directory is "%s"', [Buffer]);
end.

View File

@@ -10,5 +10,5 @@ var
begin
InitConsole('Load File', False);
Buffer := LoadFile('/sys/example.asm', FileSize);
WriteText(Buffer, FileSize);
WriteLn(Buffer, FileSize);
end.

View File

@@ -21,36 +21,36 @@ begin
if ReadFolder(FolderPath, FolderInformation, 0, 0, 0, BlocksRead) = 0 then
with FolderInformation do
Write('Folder "%s" contains %u files and/or folders.'#10#10, FolderPath, FileCount)
WriteLn('Folder "%s" contains %u files and/or folders.', [FolderPath, FileCount], 2)
else
Write('Folder "%s" can not be read.'#10, FolderPath);
WriteLn('Folder "%s" can not be read.', [FolderPath]);
Pos := 0;
while ReadFolder(FolderPath, FolderInformation, 1, Pos, 0, BlocksRead) = 0 do
begin
with FolderInformation, FileInformation[0] do
begin
Write('FileName = %s'#10, Name);
WriteLn('FileName = %s', [Name]);
with Attributes do
begin
Write( 'SizeLo = %u'#10, TInt64Rec(Size).Lo);
Write( 'SizeHi = %u'#10, TInt64Rec(Size).Hi);
WriteLn( 'SizeLo = %u', [TInt64Rec(Size).Lo]);
WriteLn( 'SizeHi = %u', [TInt64Rec(Size).Hi]);
with Modify.Date do
Write('Modify Date = %02d.%02d.%02d'#10, Day, Month, Year);
WriteLn('Modify Date = %02d.%02d.%02d', [Day, Month, Year]);
with Modify.Time do
Write('Modify Time = %02d:%02d:%02d'#10, Hours, Minutes, Seconds);
WriteLn('Modify Time = %02d:%02d:%02d', [Hours, Minutes, Seconds]);
with Access.Date do
Write('Access Date = %02d.%02d.%02d'#10, Day, Month, Year);
WriteLn('Access Date = %02d.%02d.%02d', [Day, Month, Year]);
with Access.Time do
Write('Access Time = %02d:%02d:%02d'#10, Hours, Minutes, Seconds);
WriteLn('Access Time = %02d:%02d:%02d', [Hours, Minutes, Seconds]);
with Creation.Date do
Write('Creation Date = %02d.%02d.%02d'#10, Day, Month, Year);
WriteLn('Creation Date = %02d.%02d.%02d', [Day, Month, Year]);
with Creation.Time do
Write('Creation Time = %02d:%02d:%02d'#10, Hours, Minutes, Seconds);
Write( 'Attributes = 0x%08x'#10, Attributes);
WriteLn('Creation Time = %02d:%02d:%02d', [Hours, Minutes, Seconds]);
WriteLn( 'Attributes = 0x%08x', [Attributes]);
end;
end;
Write(#10);
WriteLn;
Inc(Pos);
end;
end.