8da2b385e77822c8b8254564f25dd420f993c973
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
152 begin
155 //e_WriteLog(Format('DFWAD: searching for [%s : %s] in [%s]; current is [%s : %s] (%d, %d)', [Section, Resource, fFileName, fi.path, fi.name, SFSStrComp(fi.path, Section), SFSStrComp(fi.name, Resource)]), MSG_NOTIFY);
157 begin
158 // i found her!
159 //fn := fFileName+'::'+fi.path+fi.name;
160 //fs := SFSFileOpen(fn);
161 try
163 except
167 begin
168 e_WriteLog(Format('DFWAD: can''t open file [%s%s] in [%s]', [Section, Resource, fFileName]), MSG_WARNING);
169 break;
176 {$IFDEF SFS_DWFAD_DEBUG}
177 e_WriteLog(Format('DFWAD: file [%s%s] FOUND in [%s]; size is %d bytes', [Section, Resource, fFileName, Len]), MSG_NOTIFY);
178 {$ENDIF}
179 exit;
182 e_WriteLog(Format('DFWAD: file [%s%s] not found in [%s]', [Section, Resource, fFileName]), MSG_WARNING);
187 var
190 begin
195 begin
199 begin
208 var
210 begin
212 //e_WriteLog(Format('TWADEditor_1.ReadFile: [%s]', [FileName]), MSG_NOTIFY);
216 begin
217 //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);
219 begin
224 {.$IFDEF SFS_DWFAD_DEBUG}
225 if FileExists(rfn) then e_WriteLog(Format('TWADEditor_1.ReadFile: FOUND [%s]', [rfn]), MSG_NOTIFY);
226 {.$ENDIF}
230 {$IFDEF SFS_DWFAD_DEBUG}
232 {$ENDIF}
233 // cache this wad
238 {$IFDEF SFS_DWFAD_DEBUG}
240 {$ENDIF}
245 var
249 var
253 //f: Integer;
254 //fi: TSFSFileInfo;
255 begin
259 begin
261 Exit;
266 {$IFDEF SFS_DWFAD_DEBUG}
268 {$ENDIF}
270 try
273 begin
275 Exit;
277 except
279 Exit;
286 {$IFDEF SFS_DWFAD_DEBUG}
288 {$ENDIF}
290 {
291 for f := 0 to fIter.Count-1 do
292 begin
293 fi := fIter.Files[f];
294 if fi = nil then continue;
295 st := fIter.volume.OpenFileByIndex(f);
296 if st = nil then
297 begin
298 e_WriteLog(Format('[%s]: [%s : %s] CAN''T OPEN', [fFileName, fi.path, fi.name]), MSG_NOTIFY);
299 end
300 else
301 begin
302 e_WriteLog(Format('[%s]: [%s : %s] %u', [fFileName, fi.path, fi.name, st.size]), MSG_NOTIFY);
303 st.Free;
304 end;
305 end;
306 //fIter.volume.OpenFileByIndex(0);
307 }
313 begin