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);
141 function TWADEditor_1.GetResource (Section, Resource: string; var pData: Pointer; var Len: Integer): Boolean;
142 var
146 //fn: string;
147 begin
153 begin
156 //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);
158 begin
159 // i found her!
160 //fn := fFileName+'::'+fi.path+fi.name;
161 //fs := SFSFileOpen(fn);
162 try
164 except
168 begin
169 e_WriteLog(Format('DFWAD: can''t open file [%s%s] in [%s]', [Section, Resource, fFileName]), MSG_WARNING);
170 break;
177 {$IFDEF SFS_DWFAD_DEBUG}
179 e_WriteLog(Format('DFWAD: file [%s%s] FOUND in [%s]; size is %d bytes', [Section, Resource, fFileName, Len]), MSG_NOTIFY);
180 {$ENDIF}
181 exit;
184 e_WriteLog(Format('DFWAD: file [%s%s] not found in [%s]', [Section, Resource, fFileName]), MSG_WARNING);
189 var
192 begin
197 begin
202 begin
211 var
213 //f: Integer;
214 //fi: TSFSFileInfo;
215 begin
217 //e_WriteLog(Format('TWADEditor_1.ReadFile: [%s]', [FileName]), MSG_NOTIFY);
221 begin
222 //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);
224 begin
229 {.$IFDEF SFS_DWFAD_DEBUG}
231 if FileExists(rfn) then e_WriteLog(Format('TWADEditor_1.ReadFile: FOUND [%s]', [rfn]), MSG_NOTIFY);
232 {.$ENDIF}
236 {$IFDEF SFS_DWFAD_DEBUG}
239 {$ENDIF}
240 // cache this wad
245 {$IFDEF SFS_DWFAD_DEBUG}
248 {$ENDIF}
249 {
250 for f := 0 to fIter.Count-1 do
251 begin
252 fi := fIter.Files[f];
253 if fi = nil then continue;
254 e_WriteLog(Format('[%s]: [%s : %s] %u', [fFileName, fi.path, fi.name, fi.size]), MSG_NOTIFY);
255 end;
256 }
261 var
265 var
268 //f: Integer;
269 //fi: TSFSFileInfo;
270 begin
274 begin
276 Exit;
281 {$IFDEF SFS_DWFAD_DEBUG}
283 {$ENDIF}
285 try
288 begin
290 Exit;
292 except
294 Exit;
301 {$IFDEF SFS_DWFAD_DEBUG}
303 {$ENDIF}
305 {
306 for f := 0 to fIter.Count-1 do
307 begin
308 fi := fIter.Files[f];
309 if fi = nil then continue;
310 st := fIter.volume.OpenFileByIndex(f);
311 if st = nil then
312 begin
313 e_WriteLog(Format('[%s]: [%s : %s] CAN''T OPEN', [fFileName, fi.path, fi.name]), MSG_NOTIFY);
314 end
315 else
316 begin
317 e_WriteLog(Format('[%s]: [%s : %s] %u', [fFileName, fi.path, fi.name, st.size]), MSG_NOTIFY);
318 st.Free;
319 end;
320 end;
321 //fIter.volume.OpenFileByIndex(0);
322 }
328 begin