3 {$DEFINE SFS_DWFAD_DEBUG}
5 interface
7 uses
11 type
15 private
21 public
36 procedure g_ProcessResourceStr (ResourceStr: String; var FileName, SectionName, ResourceName: String); overload;
37 procedure g_ProcessResourceStr (ResourceStr: String; FileName, SectionName, ResourceName: PString); overload;
39 // return fixed string or empty string
43 implementation
45 uses
50 begin
53 begin
54 //e_WriteLog(Format('TWADFile.ReadFile: error looking for [%s] [%s]', [path, ExtractFileName(fname)]), MSG_NOTIFY);
56 begin
58 //e_WriteLog(Format(' looking for [%s] [%s]', [path, rfn]), MSG_NOTIFY);
60 begin
61 //e_WriteLog(Format(' looking for [%s] [%s]', [path, rfn]), MSG_NOTIFY);
65 end
66 else
67 begin
68 exit;
70 //e_WriteLog(Format('TWADFile.ReadFile: FOUND [%s]', [rfn]), MSG_NOTIFY);
71 end
72 else
73 begin
74 //if rfn <> ExtractFileName(FileName) then e_WriteLog(Format('TWADFile.ReadFile: FOUND [%s]', [rfn]), MSG_NOTIFY);
80 procedure g_ProcessResourceStr (ResourceStr: String; var FileName, SectionName, ResourceName: String);
81 var
83 begin
84 //e_WriteLog(Format('g_ProcessResourceStr0: [%s]', [ResourceStr]), MSG_NOTIFY);
87 Break;
95 SectionName := Copy(ResourceStr, i+1, Length(ResourceStr)-Length(ResourceName)-Length(FileName)-2);
99 procedure g_ProcessResourceStr (ResourceStr: AnsiString; FileName, SectionName, ResourceName: PAnsiString);
100 var
103 begin
104 //e_WriteLog(Format('g_ProcessResourceStr1: [%s]', [ResourceStr]), MSG_NOTIFY);
107 Break;
110 begin
113 end
114 else
121 begin
124 end
125 else
133 { TWADFile }
135 begin
141 begin
148 begin
154 begin
156 //if fFileName <> '' then e_WriteLog(Format('TWADFile.ReadFile: [%s] closed', [fFileName]), MSG_NOTIFY);
162 var
164 begin
168 begin
169 //writeln('[', s, '] -> [', Copy(s, 1, i-2), ']');
175 function TWADFile.GetResource (Section, Resource: string; var pData: Pointer; var Len: Integer): Boolean;
176 var
181 //fn: string;
182 begin
187 // backwards, due to possible similar names and such
189 begin
192 //e_WriteLog(Format('DFWAD: searching for [%s : %s] in [%s]; current is [%s : %s]', [Section, Resource, fFileName, fi.path, fi.name]), MSG_NOTIFY);
194 begin
195 // i found her!
196 //fn := fFileName+'::'+fi.path+fi.name;
197 //fs := SFSFileOpen(fn);
198 try
200 except
204 begin
205 e_WriteLog(Format('DFWAD: can''t open file [%s%s] in [%s]', [Section, Resource, fFileName]), MSG_WARNING);
206 break;
211 try
214 finally
216 begin
224 {$IFDEF SFS_DWFAD_DEBUG}
226 e_WriteLog(Format('DFWAD: file [%s%s] FOUND in [%s]; size is %d bytes', [Section, Resource, fFileName, Len]), MSG_NOTIFY);
227 {$ENDIF}
228 exit;
231 e_WriteLog(Format('DFWAD: file [%s%s] not found in [%s]', [Section, Resource, fFileName]), MSG_WARNING);
236 var
239 begin
244 begin
249 begin
258 var
260 //f: Integer;
261 //fi: TSFSFileInfo;
262 begin
264 //e_WriteLog(Format('TWADFile.ReadFile: [%s]', [FileName]), MSG_NOTIFY);
268 begin
270 exit;
272 {$IFDEF SFS_DWFAD_DEBUG}
274 {$ENDIF}
275 // cache this wad
276 try
278 begin
280 end
281 else
282 begin
285 except
286 exit;
291 {$IFDEF SFS_DWFAD_DEBUG}
292 if gSFSDebug then e_WriteLog(Format('TWADFile.ReadFile: [%s] opened', [fFileName]), MSG_NOTIFY);
293 {$ENDIF}
298 var
302 var
305 //f: Integer;
306 //fi: TSFSFileInfo;
307 begin
311 begin
313 Exit;
318 {$IFDEF SFS_DWFAD_DEBUG}
320 {$ENDIF}
322 try
325 begin
327 Exit;
329 except
331 Exit;
338 {$IFDEF SFS_DWFAD_DEBUG}
340 {$ENDIF}
342 {
343 for f := 0 to fIter.Count-1 do
344 begin
345 fi := fIter.Files[f];
346 if fi = nil then continue;
347 st := fIter.volume.OpenFileByIndex(f);
348 if st = nil then
349 begin
350 e_WriteLog(Format('[%s]: [%s : %s] CAN''T OPEN', [fFileName, fi.path, fi.name]), MSG_NOTIFY);
351 end
352 else
353 begin
354 e_WriteLog(Format('[%s]: [%s : %s] %u', [fFileName, fi.path, fi.name, st.size]), MSG_NOTIFY);
355 st.Free;
356 end;
357 end;
358 //fIter.volume.OpenFileByIndex(0);
359 }
365 begin