fpc/packages/libndsfpc/examples/filesystem/libfat/libfatdir/libfatdir.pp
Legolas d2dabe9a33 * updated nds/gba linker scripts and reverted some changes for 2.2.4a release
- Removed unused/outdated stuff from libndsfpc
+ Added new examples for libndsfpc
+ Added working (I hope so...) makefile.fpc for all libndsfpc/libgbafpc examples

git-svn-id: trunk@13217 -
2009-05-31 12:15:24 +00:00

49 lines
903 B
ObjectPascal

program libfatdir;
uses
ctypes, nds9, fat;
var
MyDir: PDir;
pent: pdirent;
statbuf: Tstat;
begin
// Initialise the console, required for printf
consoleDemoInit();
if (fatInitDefault()) then
begin
MyDir := opendir('/');
if (MyDir) <> nil then
begin
repeat
pent := readdir(MyDir);
_stat(pent^.d_name, statbuf);
if (strcmp('.', pent^.d_name) = 0) or (strcmp('..', pent^.d_name) = 0) then
continue;
if (S_ISDIR(statbuf.st_mode)) then
iprintf('%s <dir>'#10, pent^.d_name);
if not (S_ISDIR(statbuf.st_mode)) then
iprintf('%s %ld'#10, pent^.d_name, statbuf.st_size);
until pent = nil;
closedir(MyDir);
end else
begin
iprintf ('opendir() failure; terminating'#10);
end;
end else
begin
iprintf('fatInitDefault failure: terminating'#10);
end;
while true do
swiWaitForVBlank();
end.