c9af0bd7fd68617801c85d2caaf6310ed83bf2bb
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
160 //fn: string;
161 begin
167 begin
170 //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);
172 begin
173 // i found her!
174 //fn := fFileName+'::'+fi.path+fi.name;
175 //fs := SFSFileOpen(fn);
176 try
178 except
182 begin
183 e_WriteLog(Format('DFWAD: can''t open file [%s%s] in [%s]', [Section, Resource, fFileName]), MSG_WARNING);
184 break;
191 {$IFDEF SFS_DWFAD_DEBUG}
193 e_WriteLog(Format('DFWAD: file [%s%s] FOUND in [%s]; size is %d bytes', [Section, Resource, fFileName, Len]), MSG_NOTIFY);
194 {$ENDIF}
195 exit;
198 e_WriteLog(Format('DFWAD: file [%s%s] not found in [%s]', [Section, Resource, fFileName]), MSG_WARNING);
203 var
206 begin
211 begin
216 begin
225 var
227 //f: Integer;
228 //fi: TSFSFileInfo;
229 begin
231 //e_WriteLog(Format('TWADEditor_1.ReadFile: [%s]', [FileName]), MSG_NOTIFY);
235 begin
236 //if length(rfn) >= 4 then e_WriteLog(Format('XXXX TWADEditor_1.ReadFile: [%s] [%s]', [Copy(rfn, length(rfn)-3, 4), Copy(rfn, 1, length(rfn)-4)]), MSG_NOTIFY);
238 begin
243 {.$IFDEF SFS_DWFAD_DEBUG}
245 if FileExists(rfn) then e_WriteLog(Format('TWADEditor_1.ReadFile: FOUND [%s]', [rfn]), MSG_NOTIFY);
246 {.$ENDIF}
250 {$IFDEF SFS_DWFAD_DEBUG}
253 {$ENDIF}
254 // cache this wad
259 {$IFDEF SFS_DWFAD_DEBUG}
262 {$ENDIF}
263 {
264 for f := 0 to fIter.Count-1 do
265 begin
266 fi := fIter.Files[f];
267 if fi = nil then continue;
268 e_WriteLog(Format('[%s]: [%s : %s] %u', [fFileName, fi.path, fi.name, fi.size]), MSG_NOTIFY);
269 end;
270 }
275 var
279 var
282 //f: Integer;
283 //fi: TSFSFileInfo;
284 begin
288 begin
290 Exit;
295 {$IFDEF SFS_DWFAD_DEBUG}
297 {$ENDIF}
299 try
302 begin
304 Exit;
306 except
308 Exit;
315 {$IFDEF SFS_DWFAD_DEBUG}
317 {$ENDIF}
319 {
320 for f := 0 to fIter.Count-1 do
321 begin
322 fi := fIter.Files[f];
323 if fi = nil then continue;
324 st := fIter.volume.OpenFileByIndex(f);
325 if st = nil then
326 begin
327 e_WriteLog(Format('[%s]: [%s : %s] CAN''T OPEN', [fFileName, fi.path, fi.name]), MSG_NOTIFY);
328 end
329 else
330 begin
331 e_WriteLog(Format('[%s]: [%s : %s] %u', [fFileName, fi.path, fi.name, st.size]), MSG_NOTIFY);
332 st.Free;
333 end;
334 end;
335 //fIter.volume.OpenFileByIndex(0);
336 }
342 begin