20 |
20 |
21 function rwopsOpenRead(fname: shortstring): PSDL_RWops; |
21 function rwopsOpenRead(fname: shortstring): PSDL_RWops; |
22 function rwopsOpenWrite(fname: shortstring): PSDL_RWops; |
22 function rwopsOpenWrite(fname: shortstring): PSDL_RWops; |
23 |
23 |
24 function pfsOpenRead(fname: shortstring): PFSFile; |
24 function pfsOpenRead(fname: shortstring): PFSFile; |
|
25 function pfsOpenWrite(fname: shortstring): PFSFile; |
|
26 function pfsFlush(f: PFSFile): boolean; |
25 function pfsClose(f: PFSFile): boolean; |
27 function pfsClose(f: PFSFile): boolean; |
26 function pfsSeek(f: PFSFile; pos: QWord): boolean; |
28 function pfsSeek(f: PFSFile; pos: QWord): boolean; |
27 |
29 |
28 procedure pfsReadLn(f: PFSFile; var s: shortstring); |
30 procedure pfsReadLn(f: PFSFile; var s: shortstring); |
29 procedure pfsReadLnA(f: PFSFile; var s: ansistring); |
31 procedure pfsReadLnA(f: PFSFile; var s: ansistring); |
|
32 procedure pfsWriteLn(f: PFSFile; s: shortstring); |
30 function pfsBlockRead(f: PFSFile; buf: pointer; size: Int64): Int64; |
33 function pfsBlockRead(f: PFSFile; buf: pointer; size: Int64): Int64; |
31 function pfsEOF(f: PFSFile): boolean; |
34 function pfsEOF(f: PFSFile): boolean; |
32 function pfsEnumerateFiles(dir: shortstring): PPChar; |
35 function pfsEnumerateFiles(dir: shortstring): PPChar; |
33 procedure pfsFreeList(list: PPChar); |
36 procedure pfsFreeList(list: PPChar); |
34 |
37 |
35 function pfsExists(fname: shortstring): boolean; |
38 function pfsExists(fname: shortstring): boolean; |
|
39 function pfsMakeDir(path: shortstring): boolean; |
36 |
40 |
37 function physfsReader(L: Plua_State; f: PFSFile; sz: Psize_t) : PChar; cdecl; external PhyslayerLibName; |
41 function physfsReader(L: Plua_State; f: PFSFile; sz: Psize_t) : PChar; cdecl; external PhyslayerLibName; |
38 procedure physfsReaderSetBuffer(buf: pointer); cdecl; external PhyslayerLibName; |
42 procedure physfsReaderSetBuffer(buf: pointer); cdecl; external PhyslayerLibName; |
39 procedure hedgewarsMountPackage(filename: PChar); cdecl; external PhyslayerLibName; |
43 procedure hedgewarsMountPackage(filename: PChar); cdecl; external PhyslayerLibName; |
40 |
44 |
47 {$IFNDEF PAS2C} |
51 {$IFNDEF PAS2C} |
48 function PHYSFS_init(argv0: PChar): LongInt; cdecl; external PhysfsLibName; |
52 function PHYSFS_init(argv0: PChar): LongInt; cdecl; external PhysfsLibName; |
49 function PHYSFS_deinit(): LongInt; cdecl; external PhysfsLibName; |
53 function PHYSFS_deinit(): LongInt; cdecl; external PhysfsLibName; |
50 function PHYSFS_mount(newDir, mountPoint: PChar; appendToPath: LongBool) : LongBool; cdecl; external PhysfsLibName; |
54 function PHYSFS_mount(newDir, mountPoint: PChar; appendToPath: LongBool) : LongBool; cdecl; external PhysfsLibName; |
51 function PHYSFS_openRead(fname: PChar): PFSFile; cdecl; external PhysfsLibName; |
55 function PHYSFS_openRead(fname: PChar): PFSFile; cdecl; external PhysfsLibName; |
|
56 function PHYSFS_openWrite(fname: PChar): PFSFile; cdecl; external PhysfsLibName; |
|
57 function PHYSFS_setWriteDir(path: PChar): LongBool; cdecl; external PhysfsLibName; |
52 function PHYSFS_eof(f: PFSFile): LongBool; cdecl; external PhysfsLibName; |
58 function PHYSFS_eof(f: PFSFile): LongBool; cdecl; external PhysfsLibName; |
53 function PHYSFS_readBytes(f: PFSFile; buffer: pointer; len: Int64): Int64; cdecl; external PhysfsLibName; |
59 function PHYSFS_readBytes(f: PFSFile; buffer: pointer; len: Int64): Int64; cdecl; external PhysfsLibName; |
|
60 function PHYSFS_writeBytes(f: PFSFile; buffer: pointer; len: Int64): Int64; cdecl; external PhysfsLibName; |
54 function PHYSFS_seek(f: PFSFile; pos: QWord): LongBool; cdecl; external PhysfsLibName; |
61 function PHYSFS_seek(f: PFSFile; pos: QWord): LongBool; cdecl; external PhysfsLibName; |
|
62 function PHYSFS_flush(f: PFSFile): LongBool; cdecl; external PhysfsLibName; |
55 function PHYSFS_close(f: PFSFile): LongBool; cdecl; external PhysfsLibName; |
63 function PHYSFS_close(f: PFSFile): LongBool; cdecl; external PhysfsLibName; |
56 function PHYSFS_exists(fname: PChar): LongBool; cdecl; external PhysfsLibName; |
64 function PHYSFS_exists(fname: PChar): LongBool; cdecl; external PhysfsLibName; |
|
65 function PHYSFS_mkdir(path: PChar): LongBool; cdecl; external PhysfsLibName; |
57 function PHYSFS_getLastError(): PChar; cdecl; external PhysfsLibName; |
66 function PHYSFS_getLastError(): PChar; cdecl; external PhysfsLibName; |
58 function PHYSFS_enumerateFiles(dir: PChar): PPChar; cdecl; external PhysfsLibName; |
67 function PHYSFS_enumerateFiles(dir: PChar): PPChar; cdecl; external PhysfsLibName; |
59 procedure PHYSFS_freeList(list: PPChar); cdecl; external PhysfsLibName; |
68 procedure PHYSFS_freeList(list: PPChar); cdecl; external PhysfsLibName; |
60 {$ELSE} |
69 {$ELSE} |
61 function PHYSFS_readBytes(f: PFSFile; buffer: pointer; len: Int64): Int64; |
70 function PHYSFS_readBytes(f: PFSFile; buffer: pointer; len: Int64): Int64; |
77 function pfsOpenRead(fname: shortstring): PFSFile; |
86 function pfsOpenRead(fname: shortstring): PFSFile; |
78 begin |
87 begin |
79 exit(PHYSFS_openRead(Str2PChar(fname))); |
88 exit(PHYSFS_openRead(Str2PChar(fname))); |
80 end; |
89 end; |
81 |
90 |
|
91 function pfsOpenWrite(fname: shortstring): PFSFile; |
|
92 begin |
|
93 exit(PHYSFS_openWrite(Str2PChar(fname))); |
|
94 end; |
|
95 |
82 function pfsEOF(f: PFSFile): boolean; |
96 function pfsEOF(f: PFSFile): boolean; |
83 begin |
97 begin |
84 exit(PHYSFS_eof(f)) |
98 exit(PHYSFS_eof(f)) |
85 end; |
99 end; |
86 |
100 |
|
101 function pfsFlush(f: PFSFile): boolean; |
|
102 begin |
|
103 exit(PHYSFS_flush(f)) |
|
104 end; |
|
105 |
87 function pfsClose(f: PFSFile): boolean; |
106 function pfsClose(f: PFSFile): boolean; |
88 begin |
107 begin |
89 exit(PHYSFS_close(f)) |
108 exit(PHYSFS_close(f)) |
90 end; |
109 end; |
91 |
110 |
95 end; |
114 end; |
96 |
115 |
97 function pfsExists(fname: shortstring): boolean; |
116 function pfsExists(fname: shortstring): boolean; |
98 begin |
117 begin |
99 exit(PHYSFS_exists(Str2PChar(fname))) |
118 exit(PHYSFS_exists(Str2PChar(fname))) |
|
119 end; |
|
120 |
|
121 function pfsMakeDir(path: shortstring): boolean; |
|
122 begin |
|
123 exit(PHYSFS_mkdir(Str2PChar(path))) |
100 end; |
124 end; |
101 |
125 |
102 function pfsEnumerateFiles(dir: shortstring): PPChar; |
126 function pfsEnumerateFiles(dir: shortstring): PPChar; |
103 begin |
127 begin |
104 exit(PHYSFS_enumerateFiles(Str2PChar(dir))) |
128 exit(PHYSFS_enumerateFiles(Str2PChar(dir))) |
142 end; |
166 end; |
143 |
167 |
144 s:= s + ansistring(b) |
168 s:= s + ansistring(b) |
145 end; |
169 end; |
146 |
170 |
|
171 procedure pfsWriteLn(f: PFSFile; s: shortstring); |
|
172 var c: char; |
|
173 begin |
|
174 c:= #10; |
|
175 PHYSFS_writeBytes(f, @s[1], byte(s[0])); |
|
176 PHYSFS_writeBytes(f, @c, 1); |
|
177 end; |
|
178 |
147 function pfsBlockRead(f: PFSFile; buf: pointer; size: Int64): Int64; |
179 function pfsBlockRead(f: PFSFile; buf: pointer; size: Int64): Int64; |
148 var r: Int64; |
180 var r: Int64; |
149 begin |
181 begin |
150 r:= PHYSFS_readBytes(f, buf, size); |
182 r:= PHYSFS_readBytes(f, buf, size); |
151 |
183 |
190 pfsMount(ansistring(fp), PChar('/Fonts')); |
222 pfsMount(ansistring(fp), PChar('/Fonts')); |
191 end; |
223 end; |
192 {$ENDIF} |
224 {$ENDIF} |
193 |
225 |
194 pfsMountAtRoot(localPrefix); |
226 pfsMountAtRoot(localPrefix); |
|
227 pfsMount(userPrefix, PChar('/Config')); |
|
228 pfsMakeDir('/Config/Data'); |
|
229 pfsMakeDir('/Config/Logs'); |
195 pfsMountAtRoot(userPrefix + ansistring('/Data')); |
230 pfsMountAtRoot(userPrefix + ansistring('/Data')); |
196 pfsMount(userPrefix, PChar('/Config')); |
231 PHYSFS_setWriteDir(userPrefix); |
197 |
232 |
198 hedgewarsMountPackages; |
233 hedgewarsMountPackages; |
199 |
234 |
200 if cTestLua then |
235 if cTestLua then |
201 begin |
236 begin |