equal
deleted
inserted
replaced
13 |
13 |
14 function rwopsOpenRead(fname: shortstring): PSDL_RWops; |
14 function rwopsOpenRead(fname: shortstring): PSDL_RWops; |
15 function rwopsOpenWrite(fname: shortstring): PSDL_RWops; |
15 function rwopsOpenWrite(fname: shortstring): PSDL_RWops; |
16 |
16 |
17 function pfsOpenRead(fname: shortstring): PFSFile; |
17 function pfsOpenRead(fname: shortstring): PFSFile; |
18 function pfsEOF(f: PFSFile): boolean; |
|
19 function pfsClose(f: PFSFile): boolean; |
18 function pfsClose(f: PFSFile): boolean; |
20 |
19 |
21 procedure pfsReadLn(f: PFSFile; var s: shortstring); |
20 procedure pfsReadLn(f: PFSFile; var s: shortstring); |
|
21 function pfsBlockRead(f: PFSFile; buf: pointer; size: Int64): Int64; |
|
22 function pfsEOF(f: PFSFile): boolean; |
|
23 |
|
24 function pfsExists(fname: shortstring): boolean; |
22 |
25 |
23 implementation |
26 implementation |
24 uses uUtils, uVariables; |
27 uses uUtils, uVariables; |
25 |
28 |
26 function PHYSFS_init(argv0: PChar) : LongInt; cdecl; external; |
29 function PHYSFS_init(argv0: PChar) : LongInt; cdecl; external; |
29 function PHYSFSRWOPS_openWrite(fname: PChar): PSDL_RWops; cdecl; external; |
32 function PHYSFSRWOPS_openWrite(fname: PChar): PSDL_RWops; cdecl; external; |
30 |
33 |
31 function PHYSFS_mount(newDir, mountPoint: PChar; appendToPath: LongBool) : LongInt; cdecl; external; |
34 function PHYSFS_mount(newDir, mountPoint: PChar; appendToPath: LongBool) : LongInt; cdecl; external; |
32 function PHYSFS_openRead(fname: PChar): PFSFile; cdecl; external; |
35 function PHYSFS_openRead(fname: PChar): PFSFile; cdecl; external; |
33 function PHYSFS_eof(f: PFSFile): LongBool; cdecl; external; |
36 function PHYSFS_eof(f: PFSFile): LongBool; cdecl; external; |
34 function PHYSFS_read(f: PFSFile; buf: pointer; objSize, objCount: Longword): Int64; cdecl; external; |
37 function PHYSFS_read(f: PFSFile; buf: pointer; objSize: Longword; objCount: Longword): Int64; cdecl; external; |
35 function PHYSFS_close(f: PFSFile): LongBool; cdecl; external; |
38 function PHYSFS_close(f: PFSFile): LongBool; cdecl; external; |
|
39 function PHYSFS_exists(fname: PChar): LongBool; cdecl; external; |
36 |
40 |
37 function rwopsOpenRead(fname: shortstring): PSDL_RWops; |
41 function rwopsOpenRead(fname: shortstring): PSDL_RWops; |
38 begin |
42 begin |
39 exit(PHYSFSRWOPS_openRead(Str2PChar(fname))); |
43 exit(PHYSFSRWOPS_openRead(Str2PChar(fname))); |
40 end; |
44 end; |
57 function pfsClose(f: PFSFile): boolean; |
61 function pfsClose(f: PFSFile): boolean; |
58 begin |
62 begin |
59 exit(PHYSFS_close(f)) |
63 exit(PHYSFS_close(f)) |
60 end; |
64 end; |
61 |
65 |
|
66 function pfsExists(fname: shortstring): boolean; |
|
67 begin |
|
68 exit(PHYSFS_exists(Str2PChar(fname))) |
|
69 end; |
|
70 |
62 |
71 |
63 procedure pfsReadLn(f: PFSFile; var s: shortstring); |
72 procedure pfsReadLn(f: PFSFile; var s: shortstring); |
64 var c: char; |
73 var c: char; |
65 begin |
74 begin |
66 s[0]:= #0; |
75 s[0]:= #0; |
71 inc(s[0]); |
80 inc(s[0]); |
72 s[byte(s[0])]:= c |
81 s[byte(s[0])]:= c |
73 end |
82 end |
74 end; |
83 end; |
75 |
84 |
|
85 function pfsBlockRead(f: PFSFile; buf: pointer; size: Int64): Int64; |
|
86 var r: Int64; |
|
87 begin |
|
88 r:= PHYSFS_read(f, buf, 1, size); |
|
89 |
|
90 if r <= 0 then |
|
91 pfsBlockRead:= 0 |
|
92 else |
|
93 pfsBlockRead:= r |
|
94 end; |
|
95 |
76 procedure initModule; |
96 procedure initModule; |
77 var i: LongInt; |
97 var i: LongInt; |
78 begin |
98 begin |
79 i:= PHYSFS_init(Str2PChar(ParamStr(0))); |
99 i:= PHYSFS_init(Str2PChar(ParamStr(0))); |
80 AddFileLog('[PhysFS] init: ' + inttostr(i)); |
100 AddFileLog('[PhysFS] init: ' + inttostr(i)); |
81 |
101 |
82 i:= PHYSFS_mount(Str2PChar(PathPrefix), nil, true); |
102 i:= PHYSFS_mount(Str2PChar(PathPrefix), nil, true); |
83 AddFileLog('[PhysFS] mount ' + PathPrefix + ': ' + inttostr(i)); |
103 AddFileLog('[PhysFS] mount ' + PathPrefix + ': ' + inttostr(i)); |
84 i:= PHYSFS_mount(Str2PChar(UserPathPrefix), nil, true); |
104 i:= PHYSFS_mount(Str2PChar(UserPathPrefix + '/Data'), nil, true); |
85 AddFileLog('[PhysFS] mount ' + UserPathPrefix + ': ' + inttostr(i)); |
105 AddFileLog('[PhysFS] mount ' + UserPathPrefix + ': ' + inttostr(i)); |
86 end; |
106 end; |
87 |
107 |
88 procedure freeModule; |
108 procedure freeModule; |
89 begin |
109 begin |