7959
|
1 |
unit uPhysFSLayer;
|
|
2 |
|
|
3 |
{$LINKLIB ../bin/libphysfs.a}
|
8022
|
4 |
{$LINKLIB ../bin/libphysfsrwops.a}
|
7959
|
5 |
|
|
6 |
interface
|
8022
|
7 |
uses SDLh;
|
7959
|
8 |
|
|
9 |
procedure initModule;
|
|
10 |
procedure freeModule;
|
|
11 |
|
8025
|
12 |
function rwopsOpenRead(fname: shortstring): PSDL_RWops;
|
|
13 |
function rwopsOpenWrite(fname: shortstring): PSDL_RWops;
|
8022
|
14 |
|
7959
|
15 |
implementation
|
8022
|
16 |
uses uUtils, uVariables;
|
7959
|
17 |
|
|
18 |
function PHYSFS_init(argv0: PChar) : LongInt; cdecl; external;
|
|
19 |
function PHYSFS_deinit() : LongInt; cdecl; external;
|
8025
|
20 |
function PHYSFSRWOPS_openRead(fname: PChar): PSDL_RWops; cdecl; external;
|
|
21 |
function PHYSFSRWOPS_openWrite(fname: PChar): PSDL_RWops; cdecl; external;
|
7959
|
22 |
|
7963
|
23 |
function PHYSFS_mount(newDir, mountPoint: PChar; appendToPath: LongBool) : LongInt; cdecl; external;
|
7959
|
24 |
|
8025
|
25 |
function rwopsOpenRead(fname: shortstring): PSDL_RWops;
|
|
26 |
begin
|
|
27 |
exit(PHYSFSRWOPS_openRead(Str2PChar(fname)));
|
|
28 |
end;
|
|
29 |
|
|
30 |
function rwopsOpenWrite(fname: shortstring): PSDL_RWops;
|
7959
|
31 |
begin
|
8025
|
32 |
exit(PHYSFSRWOPS_openWrite(Str2PChar(fname)));
|
|
33 |
end;
|
8022
|
34 |
|
8025
|
35 |
procedure initModule;
|
|
36 |
var i: LongInt;
|
|
37 |
begin
|
|
38 |
i:= PHYSFS_init(Str2PChar(ParamStr(0)));
|
|
39 |
AddFileLog('[PhysFS] init: ' + inttostr(i));
|
|
40 |
|
|
41 |
i:= PHYSFS_mount(Str2PChar(PathPrefix), nil, true);
|
|
42 |
AddFileLog('[PhysFS] mount ' + PathPrefix + ': ' + inttostr(i));
|
|
43 |
i:= PHYSFS_mount(Str2PChar(UserPathPrefix), nil, true);
|
|
44 |
AddFileLog('[PhysFS] mount ' + UserPathPrefix + ': ' + inttostr(i));
|
7959
|
45 |
end;
|
|
46 |
|
|
47 |
procedure freeModule;
|
|
48 |
begin
|
|
49 |
PHYSFS_deinit;
|
|
50 |
end;
|
|
51 |
|
|
52 |
end.
|