blob: 49832b2715a7dc08e93e5004647db6539b1c4bb2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
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.
|