fpc/packages/libndsfpc/examples/filesystem/libfat/access_file/access_file.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

42 lines
819 B
ObjectPascal

program access_file;
{$mode objfpc}
uses
ctypes, nds9, fat;
var
i: integer;
size: cuint32;
text: string;
handle: P_FILE;
begin
consoleDemoInit();
printf('fatInit()...');
if (fatInitDefault()) then
begin
printf(#9 + 'Success' + #10);
handle := fopen('/test1.txt', 'r');
if handle = nil then
begin
printf('Cannot open file' + #10);
end else
begin
fseek(handle, 0, SEEK_END); // Go to end of file
size := ftell(handle); // Get current position in file, because it is the end it will be the size
fseek(handle, 0, SEEK_SET); // Go to begining of file
fread(@text, size, 1, handle); // Read all of file into memory
printf(@text);
fclose(handle); // Close file
end;
end else
printf(#9 + 'Failure' + #10);
while true do;
end.