1 {$MODE DELPHI}
4 interface
6 // does filename have one of ".wad", ".pk3", ".zip" extensions?
9 // does filepath have ".XXX:\" in it?
12 // adds ".wad" extension if filename doesn't have one of ".wad", ".pk3", ".zip"
15 // convert number to strig with nice commas
20 // `true` if strings are equal; ignoring case for cp1251
27 // `pathname` will be modified if path is valid
28 // `lastIsDir` should be `true` if we are searching for directory
29 // nobody cares about shitdoze, so i'll use the same code path for it
33 implementation
35 uses
36 SysUtils;
40 begin
47 begin
54 var
57 begin
60 begin
64 begin
67 begin
69 exit;
78 var
80 begin
84 begin
91 begin
93 begin
95 end
96 else
97 begin
99 begin
101 end
102 else
103 begin
115 var
117 begin
125 // ////////////////////////////////////////////////////////////////////////// //
126 // utils
127 // `ch`: utf8 start
128 // -1: invalid utf8
130 begin
142 var
144 begin
148 begin
154 // check other sequence bytes
156 begin
166 // ////////////////////////////////////////////////////////////////////////// //
167 const
169 $0402,$0403,$201A,$0453,$201E,$2026,$2020,$2021,$20AC,$2030,$0409,$2039,$040A,$040C,$040B,$040F,
170 $0452,$2018,$2019,$201C,$201D,$2022,$2013,$2014,$003F,$2122,$0459,$203A,$045A,$045C,$045B,$045F,
171 $00A0,$040E,$045E,$0408,$00A4,$0490,$00A6,$00A7,$0401,$00A9,$0404,$00AB,$00AC,$00AD,$00AE,$0407,
172 $00B0,$00B1,$0406,$0456,$0491,$00B5,$00B6,$00B7,$0451,$2116,$0454,$00BB,$0458,$0405,$0455,$0457,
173 $0410,$0411,$0412,$0413,$0414,$0415,$0416,$0417,$0418,$0419,$041A,$041B,$041C,$041D,$041E,$041F,
174 $0420,$0421,$0422,$0423,$0424,$0425,$0426,$0427,$0428,$0429,$042A,$042B,$042C,$042D,$042E,$042F,
175 $0430,$0431,$0432,$0433,$0434,$0435,$0436,$0437,$0438,$0439,$043A,$043B,$043C,$043D,$043E,$043F,
177 );
181 var
183 begin
184 (* The following encodings are valid, except for the 5 and 6 byte
185 * combinations:
186 * 0xxxxxxx
187 * 110xxxxx 10xxxxxx
188 * 1110xxxx 10xxxxxx 10xxxxxx
189 * 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
190 * 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
191 * 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
192 *)
200 // mask out unused bits
208 // now continue
210 begin
218 // done, try 1251
220 // alas
225 var
227 begin
231 begin
242 // ////////////////////////////////////////////////////////////////////////// //
243 // `pathname` will be modified if path is valid
244 // `lastIsDir` should be `true` if we are searching for directory
245 // nobody cares about shitdoze, so i'll use the same code path for it
247 var
255 begin
260 begin
261 // remove trailing slashes
264 // extract name
267 begin
271 // remove trailing slashes again
274 //writeln(Format('npt=[%s]; newname=[%s]; curname=[%s]; wantdir=%d', [npt, newname, curname, Integer(wantdir)]));
275 // try the easiest case first
278 begin
280 begin
281 // i found her!
284 continue;
287 //writeln(Format('npt=[%s]; newname=[%s]; curname=[%s]; wantdir=%d', [npt, newname, curname, Integer(wantdir)]));
288 // alas, either not found, or invalid attributes
290 try
292 repeat
294 begin
295 // i found her!
299 break;
302 finally