4434e45e7adde1ae8fc8501fae4a526763d44674
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;
52 // return fixed string or empty string
56 implementation
58 uses
63 var
65 begin
70 begin
71 //e_WriteLog(Format('TWADEditor_1.ReadFile: error looking for [%s] [%s]', [path, ExtractFileName(fname)]), MSG_NOTIFY);
73 begin
75 //e_WriteLog(Format(' looking for [%s] [%s]', [path, rfn]), MSG_NOTIFY);
77 begin
78 //e_WriteLog(Format(' looking for [%s] [%s]', [path, rfn]), MSG_NOTIFY);
82 end
83 else
84 begin
85 exit;
87 //e_WriteLog(Format('TWADEditor_1.ReadFile: FOUND [%s]', [rfn]), MSG_NOTIFY);
88 end
89 else
90 begin
91 //if rfn <> ExtractFileName(FileName) then e_WriteLog(Format('TWADEditor_1.ReadFile: FOUND [%s]', [rfn]), MSG_NOTIFY);
97 procedure g_ProcessResourceStr (ResourceStr: String; var FileName, SectionName, ResourceName: String);
98 var
101 begin
102 //e_WriteLog(Format('g_ProcessResourceStr0: [%s]', [ResourceStr]), MSG_NOTIFY);
105 Break;
113 SectionName := Copy(ResourceStr, i+1, Length(ResourceStr)-Length(ResourceName)-Length(FileName)-2);
117 procedure g_ProcessResourceStr (ResourceStr: AnsiString; FileName, SectionName, ResourceName: PAnsiString);
118 var
121 begin
122 //e_WriteLog(Format('g_ProcessResourceStr1: [%s]', [ResourceStr]), MSG_NOTIFY);
125 Break;
128 begin
131 end
132 else
139 begin
142 end
143 else
151 { TWADEditor_1 }
153 begin
159 begin
166 begin
172 begin
174 //if fFileName <> '' then e_WriteLog(Format('TWADEditor_1.ReadFile: [%s] closed', [fFileName]), MSG_NOTIFY);
180 var
182 begin
186 begin
187 //writeln('[', s, '] -> [', Copy(s, 1, i-2), ']');
193 function TWADEditor_1.GetResource (Section, Resource: string; var pData: Pointer; var Len: Integer): Boolean;
194 var
199 //fn: string;
200 begin
205 // backwards, due to possible similar names and such
207 begin
210 //e_WriteLog(Format('DFWAD: searching for [%s : %s] in [%s]; current is [%s : %s]', [Section, Resource, fFileName, fi.path, fi.name]), MSG_NOTIFY);
212 begin
213 // i found her!
214 //fn := fFileName+'::'+fi.path+fi.name;
215 //fs := SFSFileOpen(fn);
216 try
218 except
222 begin
223 e_WriteLog(Format('DFWAD: can''t open file [%s%s] in [%s]', [Section, Resource, fFileName]), MSG_WARNING);
224 break;
229 try
232 finally
234 begin
242 {$IFDEF SFS_DWFAD_DEBUG}
244 e_WriteLog(Format('DFWAD: file [%s%s] FOUND in [%s]; size is %d bytes', [Section, Resource, fFileName, Len]), MSG_NOTIFY);
245 {$ENDIF}
246 exit;
249 e_WriteLog(Format('DFWAD: file [%s%s] not found in [%s]', [Section, Resource, fFileName]), MSG_WARNING);
254 var
257 begin
262 begin
267 begin
276 var
278 //f: Integer;
279 //fi: TSFSFileInfo;
280 begin
282 //e_WriteLog(Format('TWADEditor_1.ReadFile: [%s]', [FileName]), MSG_NOTIFY);
286 begin
288 exit;
290 {$IFDEF SFS_DWFAD_DEBUG}
292 {$ENDIF}
293 // cache this wad
294 try
296 begin
298 end
299 else
300 begin
303 except
304 exit;
309 {$IFDEF SFS_DWFAD_DEBUG}
310 if gSFSDebug then e_WriteLog(Format('TWADEditor_1.ReadFile: [%s] opened', [fFileName]), MSG_NOTIFY);
311 {$ENDIF}
316 var
320 var
323 //f: Integer;
324 //fi: TSFSFileInfo;
325 begin
329 begin
331 Exit;
336 {$IFDEF SFS_DWFAD_DEBUG}
338 {$ENDIF}
340 try
343 begin
345 Exit;
347 except
349 Exit;
356 {$IFDEF SFS_DWFAD_DEBUG}
358 {$ENDIF}
360 {
361 for f := 0 to fIter.Count-1 do
362 begin
363 fi := fIter.Files[f];
364 if fi = nil then continue;
365 st := fIter.volume.OpenFileByIndex(f);
366 if st = nil then
367 begin
368 e_WriteLog(Format('[%s]: [%s : %s] CAN''T OPEN', [fFileName, fi.path, fi.name]), MSG_NOTIFY);
369 end
370 else
371 begin
372 e_WriteLog(Format('[%s]: [%s : %s] %u', [fFileName, fi.path, fi.name, st.size]), MSG_NOTIFY);
373 st.Free;
374 end;
375 end;
376 //fIter.volume.OpenFileByIndex(0);
377 }
383 begin