252075fac9b76aae2c7a4fc614c77221c35cf015
3 {$DEFINE SFS_DWFAD_DEBUG}
5 interface
7 uses
11 type
15 private
21 public
29 function GetResource (Section, Resource: AnsiString; var pData: Pointer; var Len: Integer): Boolean;
36 procedure g_ProcessResourceStr (ResourceStr: AnsiString; var FileName, SectionName, ResourceName: AnsiString); overload;
37 procedure g_ProcessResourceStr (ResourceStr: AnsiString; FileName, SectionName, ResourceName: PString); overload;
39 // return fixed AnsiString or empty AnsiString
43 implementation
45 uses
50 begin
53 begin
54 //e_WriteLog(Format('findDiskWad: error looking for [%s]', [fname]), MSG_NOTIFY);
56 begin
58 //e_WriteLog(Format(' looking for [%s]', [fname]), MSG_NOTIFY);
60 begin
62 //e_WriteLog(Format(' looking for [%s]', [fname]), MSG_NOTIFY);
65 end
66 else
67 begin
68 exit;
71 //e_WriteLog(Format('findDiskWad: FOUND [%s]', [fname]), MSG_NOTIFY);
76 procedure g_ProcessResourceStr (ResourceStr: AnsiString; var FileName, SectionName, ResourceName: AnsiString);
77 var
79 begin
80 //e_WriteLog(Format('g_ProcessResourceStr0: [%s]', [ResourceStr]), MSG_NOTIFY);
83 for a := i+1 to Length(ResourceStr) do if (ResourceStr[a] = '\') or (ResourceStr[a] = '/') then Break;
85 SectionName := Copy(ResourceStr, i+1, Length(ResourceStr)-Length(ResourceName)-Length(FileName)-2);
89 procedure g_ProcessResourceStr (ResourceStr: AnsiString; FileName, SectionName, ResourceName: PAnsiString);
90 var
92 begin
93 //e_WriteLog(Format('g_ProcessResourceStr1: [%s]', [ResourceStr]), MSG_NOTIFY);
96 begin
99 end
100 else
101 begin
104 for a := i+1 to Length(ResourceStr) do if (ResourceStr[a] = '\') or (ResourceStr[a] = '/') then break;
106 begin
109 end
110 else
111 begin
118 { TWADFile }
120 begin
126 begin
133 begin
139 begin
141 //if fFileName <> '' then e_WriteLog(Format('TWADFile.ReadFile: [%s] closed', [fFileName]), MSG_NOTIFY);
147 var
149 begin
153 begin
154 //writeln('[', s, '] -> [', Copy(s, 1, i-2), ']');
160 function TWADFile.GetResource (Section, Resource: AnsiString; var pData: Pointer; var Len: Integer): Boolean;
161 var
166 //fn: AnsiString;
167 begin
172 // backwards, due to possible similar names and such
174 begin
177 //e_WriteLog(Format('DFWAD: searching for [%s : %s] in [%s]; current is [%s : %s]', [Section, Resource, fFileName, fi.path, fi.name]), MSG_NOTIFY);
179 begin
180 // i found her!
181 //fn := fFileName+'::'+fi.path+fi.name;
182 //fs := SFSFileOpen(fn);
183 try
185 except
189 begin
190 e_WriteLog(Format('DFWAD: can''t open file [%s%s] in [%s]', [Section, Resource, fFileName]), MSG_WARNING);
191 break;
196 try
199 finally
201 begin
209 {$IFDEF SFS_DWFAD_DEBUG}
211 e_WriteLog(Format('DFWAD: file [%s%s] FOUND in [%s]; size is %d bytes', [Section, Resource, fFileName, Len]), MSG_NOTIFY);
212 {$ENDIF}
213 exit;
216 e_WriteLog(Format('DFWAD: file [%s%s] not found in [%s]', [Section, Resource, fFileName]), MSG_WARNING);
221 var
224 begin
229 begin
234 begin
243 var
245 //f: Integer;
246 //fi: TSFSFileInfo;
247 begin
249 //e_WriteLog(Format('TWADFile.ReadFile: [%s]', [FileName]), MSG_NOTIFY);
253 begin
255 exit;
257 {$IFDEF SFS_DWFAD_DEBUG}
259 {$ENDIF}
260 // cache this wad
261 try
263 begin
265 end
266 else
267 begin
270 except
271 exit;
276 {$IFDEF SFS_DWFAD_DEBUG}
277 if gSFSDebug then e_WriteLog(Format('TWADFile.ReadFile: [%s] opened', [fFileName]), MSG_NOTIFY);
278 {$ENDIF}
283 var
287 var
290 //f: Integer;
291 //fi: TSFSFileInfo;
292 begin
296 begin
298 Exit;
303 {$IFDEF SFS_DWFAD_DEBUG}
305 {$ENDIF}
307 try
310 begin
312 Exit;
314 except
316 Exit;
323 {$IFDEF SFS_DWFAD_DEBUG}
325 {$ENDIF}
327 {
328 for f := 0 to fIter.Count-1 do
329 begin
330 fi := fIter.Files[f];
331 if fi = nil then continue;
332 st := fIter.volume.OpenFileByIndex(f);
333 if st = nil then
334 begin
335 e_WriteLog(Format('[%s]: [%s : %s] CAN''T OPEN', [fFileName, fi.path, fi.name]), MSG_NOTIFY);
336 end
337 else
338 begin
339 e_WriteLog(Format('[%s]: [%s : %s] %u', [fFileName, fi.path, fi.name, st.size]), MSG_NOTIFY);
340 st.Free;
341 end;
342 end;
343 //fIter.volume.OpenFileByIndex(0);
344 }
350 begin