de670694b81fe44207506b355c7351b3921ea86c
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
166 // backwards, due to possible similar names and such
168 begin
171 //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);
173 begin
174 // i found her!
175 //fn := fFileName+'::'+fi.path+fi.name;
176 //fs := SFSFileOpen(fn);
177 try
179 except
183 begin
184 e_WriteLog(Format('DFWAD: can''t open file [%s%s] in [%s]', [Section, Resource, fFileName]), MSG_WARNING);
185 break;
192 {$IFDEF SFS_DWFAD_DEBUG}
194 e_WriteLog(Format('DFWAD: file [%s%s] FOUND in [%s]; size is %d bytes', [Section, Resource, fFileName, Len]), MSG_NOTIFY);
195 {$ENDIF}
196 exit;
199 e_WriteLog(Format('DFWAD: file [%s%s] not found in [%s]', [Section, Resource, fFileName]), MSG_WARNING);
204 var
207 begin
212 begin
217 begin
226 var
228 //f: Integer;
229 //fi: TSFSFileInfo;
230 begin
232 //e_WriteLog(Format('TWADEditor_1.ReadFile: [%s]', [FileName]), MSG_NOTIFY);
236 begin
237 //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);
239 begin
244 {.$IFDEF SFS_DWFAD_DEBUG}
246 if FileExists(rfn) then e_WriteLog(Format('TWADEditor_1.ReadFile: FOUND [%s]', [rfn]), MSG_NOTIFY);
247 {.$ENDIF}
251 {$IFDEF SFS_DWFAD_DEBUG}
254 {$ENDIF}
255 // cache this wad
260 {$IFDEF SFS_DWFAD_DEBUG}
263 {$ENDIF}
264 {
265 for f := 0 to fIter.Count-1 do
266 begin
267 fi := fIter.Files[f];
268 if fi = nil then continue;
269 e_WriteLog(Format('[%s]: [%s : %s] %u', [fFileName, fi.path, fi.name, fi.size]), MSG_NOTIFY);
270 end;
271 }
276 var
280 var
283 //f: Integer;
284 //fi: TSFSFileInfo;
285 begin
289 begin
291 Exit;
296 {$IFDEF SFS_DWFAD_DEBUG}
298 {$ENDIF}
300 try
303 begin
305 Exit;
307 except
309 Exit;
316 {$IFDEF SFS_DWFAD_DEBUG}
318 {$ENDIF}
320 {
321 for f := 0 to fIter.Count-1 do
322 begin
323 fi := fIter.Files[f];
324 if fi = nil then continue;
325 st := fIter.volume.OpenFileByIndex(f);
326 if st = nil then
327 begin
328 e_WriteLog(Format('[%s]: [%s : %s] CAN''T OPEN', [fFileName, fi.path, fi.name]), MSG_NOTIFY);
329 end
330 else
331 begin
332 e_WriteLog(Format('[%s]: [%s : %s] %u', [fFileName, fi.path, fi.name, st.size]), MSG_NOTIFY);
333 st.Free;
334 end;
335 end;
336 //fIter.volume.OpenFileByIndex(0);
337 }
343 begin