079dc7d508d3464e1328a72496cc24c7e5699b62
3 {$DEFINE SFS_DWFAD_DEBUG}
5 interface
7 uses
11 type
15 private
21 public
35 {
36 const
37 DFWAD_NOERROR = 0;
38 DFWAD_ERROR_WADNOTFOUND = -1;
39 DFWAD_ERROR_CANTOPENWAD = -2;
40 DFWAD_ERROR_RESOURCENOTFOUND = -3;
41 DFWAD_ERROR_FILENOTWAD = -4;
42 DFWAD_ERROR_WADNOTLOADED = -5;
43 DFWAD_ERROR_READRESOURCE = -6;
44 DFWAD_ERROR_READWAD = -7;
45 DFWAD_ERROR_WRONGVERSION = -8;
46 }
49 procedure g_ProcessResourceStr (ResourceStr: String; var FileName, SectionName, ResourceName: String); overload;
50 procedure g_ProcessResourceStr (ResourceStr: String; FileName, SectionName, ResourceName: PString); overload;
53 implementation
55 uses
59 procedure g_ProcessResourceStr (ResourceStr: String; var FileName, SectionName, ResourceName: String);
60 var
63 begin
64 //e_WriteLog(Format('g_ProcessResourceStr0: [%s]', [ResourceStr]), MSG_NOTIFY);
67 Break;
75 SectionName := Copy(ResourceStr, i+1, Length(ResourceStr)-Length(ResourceName)-Length(FileName)-2);
79 procedure g_ProcessResourceStr (ResourceStr: AnsiString; FileName, SectionName, ResourceName: PAnsiString);
80 var
83 begin
84 //e_WriteLog(Format('g_ProcessResourceStr1: [%s]', [ResourceStr]), MSG_NOTIFY);
87 Break;
90 begin
93 end
94 else
101 begin
104 end
105 else
113 { TWADEditor_1 }
115 begin
121 begin
128 begin
134 begin
136 //if fFileName <> '' then e_WriteLog(Format('TWADEditor_1.ReadFile: [%s] closed', [fFileName]), MSG_NOTIFY);
142 var
144 begin
148 begin
149 //writeln('[', s, '] -> [', Copy(s, 1, i-2), ']');
155 function TWADEditor_1.GetResource (Section, Resource: string; var pData: Pointer; var Len: Integer): Boolean;
156 var
161 //fn: string;
162 begin
167 // backwards, due to possible similar names and such
169 begin
172 //e_WriteLog(Format('DFWAD: searching for [%s : %s] in [%s]; current is [%s : %s] (%d, %d)', [Section, Resource, fFileName, fi.path, fi.name, SFSStrEqu(fi.path, Section), SFSStrEqu(fi.name, Resource)]), MSG_NOTIFY);
174 begin
175 // i found her!
176 //fn := fFileName+'::'+fi.path+fi.name;
177 //fs := SFSFileOpen(fn);
178 try
180 except
184 begin
185 e_WriteLog(Format('DFWAD: can''t open file [%s%s] in [%s]', [Section, Resource, fFileName]), MSG_WARNING);
186 break;
191 try
194 finally
196 begin
204 {$IFDEF SFS_DWFAD_DEBUG}
206 e_WriteLog(Format('DFWAD: file [%s%s] FOUND in [%s]; size is %d bytes', [Section, Resource, fFileName, Len]), MSG_NOTIFY);
207 {$ENDIF}
208 exit;
211 e_WriteLog(Format('DFWAD: file [%s%s] not found in [%s]', [Section, Resource, fFileName]), MSG_WARNING);
216 var
219 begin
224 begin
229 begin
238 var
240 //f: Integer;
241 //fi: TSFSFileInfo;
242 begin
244 //e_WriteLog(Format('TWADEditor_1.ReadFile: [%s]', [FileName]), MSG_NOTIFY);
249 begin
250 //{if gSFSDebug then} e_WriteLog(Format('TWADEditor_1.ReadFile: error looking for [%s] [%s]', [path, ExtractFileName(FileName)]), MSG_NOTIFY);
252 begin
254 //{if gSFSDebug then} e_WriteLog(Format(' looking for [%s] [%s]', [path, rfn]), MSG_NOTIFY);
256 begin
257 //{if gSFSDebug then} e_WriteLog(Format(' looking for [%s] [%s]', [path, rfn]), MSG_NOTIFY);
261 end
262 else
263 begin
264 exit;
266 //{if gSFSDebug then} e_WriteLog(Format('TWADEditor_1.ReadFile: FOUND [%s]', [rfn]), MSG_NOTIFY);
267 end
268 else
269 begin
270 //if rfn <> ExtractFileName(FileName) then e_WriteLog(Format('TWADEditor_1.ReadFile: FOUND [%s]', [rfn]), MSG_NOTIFY);
272 {$IFDEF SFS_DWFAD_DEBUG}
274 {$ENDIF}
275 // cache this wad
277 try
279 except
280 exit;
285 {$IFDEF SFS_DWFAD_DEBUG}
288 {$ENDIF}
289 {
290 for f := 0 to fIter.Count-1 do
291 begin
292 fi := fIter.Files[f];
293 if fi = nil then continue;
294 e_WriteLog(Format('[%s]: [%s : %s] %u', [fFileName, fi.path, fi.name, fi.size]), MSG_NOTIFY);
295 end;
296 }
301 var
305 var
308 //f: Integer;
309 //fi: TSFSFileInfo;
310 begin
314 begin
316 Exit;
321 {$IFDEF SFS_DWFAD_DEBUG}
323 {$ENDIF}
325 try
328 begin
330 Exit;
332 except
334 Exit;
341 {$IFDEF SFS_DWFAD_DEBUG}
343 {$ENDIF}
345 {
346 for f := 0 to fIter.Count-1 do
347 begin
348 fi := fIter.Files[f];
349 if fi = nil then continue;
350 st := fIter.volume.OpenFileByIndex(f);
351 if st = nil then
352 begin
353 e_WriteLog(Format('[%s]: [%s : %s] CAN''T OPEN', [fFileName, fi.path, fi.name]), MSG_NOTIFY);
354 end
355 else
356 begin
357 e_WriteLog(Format('[%s]: [%s : %s] %u', [fFileName, fi.path, fi.name, st.size]), MSG_NOTIFY);
358 st.Free;
359 end;
360 end;
361 //fIter.volume.OpenFileByIndex(0);
362 }
368 begin