1 {$MODE DELPHI}
4 interface
6 uses
10 // does filename have one of ".wad", ".pk3", ".zip" extensions?
13 // does filepath have ".XXX:\" in it?
16 // adds ".wad" extension if filename doesn't have one of ".wad", ".pk3", ".zip"
19 // convert number to strig with nice commas
24 // `true` if strings are equal; ignoring case for cp1251
31 // `pathname` will be modified if path is valid
32 // `lastIsDir` should be `true` if we are searching for directory
33 // nobody cares about shitdoze, so i'll use the same code path for it
36 // they throws
41 implementation
44 begin
51 begin
58 var
61 begin
64 begin
68 begin
71 begin
73 exit;
82 var
84 begin
88 begin
95 begin
97 begin
99 end
100 else
101 begin
103 begin
105 end
106 else
107 begin
119 var
121 begin
129 // ////////////////////////////////////////////////////////////////////////// //
130 // utils
131 // `ch`: utf8 start
132 // -1: invalid utf8
134 begin
146 var
148 begin
152 begin
158 // check other sequence bytes
160 begin
170 // ////////////////////////////////////////////////////////////////////////// //
171 const
173 $0402,$0403,$201A,$0453,$201E,$2026,$2020,$2021,$20AC,$2030,$0409,$2039,$040A,$040C,$040B,$040F,
174 $0452,$2018,$2019,$201C,$201D,$2022,$2013,$2014,$003F,$2122,$0459,$203A,$045A,$045C,$045B,$045F,
175 $00A0,$040E,$045E,$0408,$00A4,$0490,$00A6,$00A7,$0401,$00A9,$0404,$00AB,$00AC,$00AD,$00AE,$0407,
176 $00B0,$00B1,$0406,$0456,$0491,$00B5,$00B6,$00B7,$0451,$2116,$0454,$00BB,$0458,$0405,$0455,$0457,
177 $0410,$0411,$0412,$0413,$0414,$0415,$0416,$0417,$0418,$0419,$041A,$041B,$041C,$041D,$041E,$041F,
178 $0420,$0421,$0422,$0423,$0424,$0425,$0426,$0427,$0428,$0429,$042A,$042B,$042C,$042D,$042E,$042F,
179 $0430,$0431,$0432,$0433,$0434,$0435,$0436,$0437,$0438,$0439,$043A,$043B,$043C,$043D,$043E,$043F,
181 );
185 var
187 begin
188 (* The following encodings are valid, except for the 5 and 6 byte
189 * combinations:
190 * 0xxxxxxx
191 * 110xxxxx 10xxxxxx
192 * 1110xxxx 10xxxxxx 10xxxxxx
193 * 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
194 * 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
195 * 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
196 *)
204 // mask out unused bits
212 // now continue
214 begin
222 // done, try 1251
224 // alas
229 var
231 begin
235 begin
246 // ////////////////////////////////////////////////////////////////////////// //
247 // `pathname` will be modified if path is valid
248 // `lastIsDir` should be `true` if we are searching for directory
249 // nobody cares about shitdoze, so i'll use the same code path for it
251 var
259 begin
264 begin
265 // remove trailing slashes
268 // extract name
271 begin
275 // remove trailing slashes again
278 //writeln(Format('npt=[%s]; newname=[%s]; curname=[%s]; wantdir=%d', [npt, newname, curname, Integer(wantdir)]));
279 // try the easiest case first
282 begin
284 begin
285 // i found her!
288 continue;
291 //writeln(Format('npt=[%s]; newname=[%s]; curname=[%s]; wantdir=%d', [npt, newname, curname, Integer(wantdir)]));
292 // alas, either not found, or invalid attributes
294 try
296 repeat
298 begin
299 // i found her!
303 break;
306 finally
316 begin
322 var
324 begin
327 begin