mirror of
https://github.com/vapaamies/KolibriOS.git
synced 2025-09-24 08:03:49 +02:00
CRT unit with colored console example added
This commit is contained in:
@@ -1,19 +1,13 @@
|
||||
program ReadFolderApp;
|
||||
|
||||
uses
|
||||
KolibriOS;
|
||||
KolibriOS, CRT;
|
||||
|
||||
type
|
||||
TInt64Rec = packed record
|
||||
Lo, Hi: LongWord;
|
||||
end;
|
||||
|
||||
var
|
||||
hConsole: Pointer;
|
||||
ConsoleInit: procedure(WndWidth, WndHeight, ScrWidth, ScrHeight: LongWord; Caption: PKolibriChar); stdcall;
|
||||
ConsoleExit: procedure(bCloseWindow: Cardinal); stdcall;
|
||||
printf: function(const Format: PKolibriChar): Integer; cdecl varargs;
|
||||
|
||||
const
|
||||
FolderPath = '/sys';
|
||||
|
||||
@@ -23,46 +17,42 @@ var
|
||||
Pos: LongWord;
|
||||
|
||||
begin
|
||||
hConsole := LoadLibrary('/sys/lib/console.obj');
|
||||
ConsoleInit := GetProcAddress(hConsole, 'con_init');
|
||||
ConsoleExit := GetProcAddress(hConsole, 'con_exit');
|
||||
printf := GetProcAddress(hConsole, 'con_printf');
|
||||
ConsoleInit('Read Folder');
|
||||
|
||||
if ReadFolder(FolderPath, FolderInformation, 0, 0, 0, BlocksRead) = 0 then
|
||||
with FolderInformation do
|
||||
begin
|
||||
ConsoleInit($FFFFFFFF, $FFFFFFFF, $FFFFFFFF, {11 printf In Loop}11 * FileCount + {2 printf below}2 + 1, 'ReadFolder');
|
||||
printf('Folder "%s" contains %u files and/or folders.'#10, FolderPath, FileCount);
|
||||
printf(#10);
|
||||
end
|
||||
Write('Folder "%s" contains %u files and/or folders.'#10#10, FolderPath, FileCount)
|
||||
else
|
||||
begin
|
||||
ConsoleInit($FFFFFFFF, $FFFFFFFF, $FFFFFFFF, $FFFFFFFF, 'Read Folder');
|
||||
printf('Folder "%s" can not be read.'#10, FolderPath);
|
||||
end;
|
||||
Write('Folder "%s" can not be read.'#10, FolderPath);
|
||||
|
||||
Pos := 0;
|
||||
while ReadFolder(FolderPath, FolderInformation, 1, Pos, 0, BlocksRead) = 0 do
|
||||
begin
|
||||
with FolderInformation, FileInformation[0] do
|
||||
begin
|
||||
printf('FileName = %s'#10, Name);
|
||||
Write('FileName = %s'#10, Name);
|
||||
with Attributes do
|
||||
begin
|
||||
printf('SizeLo = %u'#10, TInt64Rec(Size).Lo);
|
||||
printf('SizeHi = %u'#10, TInt64Rec(Size).Hi);
|
||||
with Modify.Date do printf('modifyDate = %02d.%02d.%02d'#10, Day, Month, Year);
|
||||
with Modify.Time do printf('modifyTime = %02d:%02d:%02d'#10, Hours, Minutes, Seconds);
|
||||
with Access.Date do printf('AccessDate = %02d.%02d.%02d'#10, Day, Month, Year);
|
||||
with Access.Time do printf('AccessTime = %02d:%02d:%02d'#10, Hours, Minutes, Seconds);
|
||||
with Creation.Date do printf('CreationDate = %02d.%02d.%02d'#10, Day, Month, Year);
|
||||
with Creation.Time do printf('CreationTime = %02d:%02d:%02d'#10, Hours, Minutes, Seconds);
|
||||
printf('Attributes = 0x%08x'#10, Attributes);
|
||||
Write( 'SizeLo = %u'#10, TInt64Rec(Size).Lo);
|
||||
Write( 'SizeHi = %u'#10, TInt64Rec(Size).Hi);
|
||||
with Modify.Date do
|
||||
Write('Modify Date = %02d.%02d.%02d'#10, Day, Month, Year);
|
||||
with Modify.Time do
|
||||
Write('Modify Time = %02d:%02d:%02d'#10, Hours, Minutes, Seconds);
|
||||
with Access.Date do
|
||||
Write('Access Date = %02d.%02d.%02d'#10, Day, Month, Year);
|
||||
with Access.Time do
|
||||
Write('Access Time = %02d:%02d:%02d'#10, Hours, Minutes, Seconds);
|
||||
with Creation.Date do
|
||||
Write('Creation Date = %02d.%02d.%02d'#10, Day, Month, Year);
|
||||
with Creation.Time do
|
||||
Write('Creation Time = %02d:%02d:%02d'#10, Hours, Minutes, Seconds);
|
||||
Write( 'Attributes = 0x%08x'#10, Attributes);
|
||||
end;
|
||||
end;
|
||||
printf(#10);
|
||||
Write(#10);
|
||||
Inc(Pos);
|
||||
end;
|
||||
|
||||
ConsoleExit(0);
|
||||
ConsoleExit(False);
|
||||
end.
|
||||
|
Reference in New Issue
Block a user