1 | unit OniDataClass;
|
---|
2 | interface
|
---|
3 | uses Data, Classes, SysUtils, StrUtils,
|
---|
4 | Dialogs, ABSDecUtil, ABSMain, DB, Windows;
|
---|
5 |
|
---|
6 | type
|
---|
7 | TOniData = class
|
---|
8 | private
|
---|
9 | FFileName: String;
|
---|
10 | FLevelInfo: TLevelInfo;
|
---|
11 | FBackend: Integer;
|
---|
12 | Fos_mac: Boolean;
|
---|
13 | protected
|
---|
14 | public
|
---|
15 | property FileName: String Read FFileName Write FFileName;
|
---|
16 | property Backend: Integer Read FBackend Write FBackend;
|
---|
17 | property OSisMac: Boolean Read Fos_mac Write Fos_mac;
|
---|
18 | property LevelInfo: TLevelinfo Read FLevelInfo Write FLevelInfo;
|
---|
19 |
|
---|
20 | constructor Create(filename: String; var Result: Boolean); virtual; abstract;
|
---|
21 | procedure Close; virtual; abstract;
|
---|
22 |
|
---|
23 | function GetFileInfo(fileid: Integer): TFileInfo; virtual;
|
---|
24 | function GetFilesList(ext: String; pattern: String;
|
---|
25 | NoEmptyFiles: Boolean; sort: TSortType): TStringArray; virtual; abstract;
|
---|
26 | function GetFilesCount: LongWord; virtual; abstract;
|
---|
27 | function GetExtensionsList: TStringArray; virtual; abstract;
|
---|
28 | function GetExtendedExtensionsList: TExtensionsMap; virtual; abstract;
|
---|
29 | function ExtractFileID(Name: String): Integer;
|
---|
30 | function GetFileIDByName(Name: String): Integer;
|
---|
31 |
|
---|
32 | function LoadDatFile(fileid: LongWord): Tdata; virtual; abstract;
|
---|
33 | procedure UpdateDatFile(fileid: LongWord; Data: Tdata); virtual; abstract;
|
---|
34 | procedure LoadDatFilePart(fileid, offset, size: LongWord; target: Pointer);
|
---|
35 | virtual; abstract;
|
---|
36 | procedure UpdateDatFilePart(fileid, offset, size: LongWord; target: Pointer);
|
---|
37 | virtual; abstract;
|
---|
38 |
|
---|
39 | function GetRawList(fileid: LongWord): TRawList; virtual; abstract;
|
---|
40 | function GetRawInfo(fileid, dat_offset: LongWord): TRawInfo;
|
---|
41 | procedure LoadRawFile(fileid, dat_offset: LongWord; target: Pointer);
|
---|
42 | virtual; abstract;
|
---|
43 | procedure UpdateRawFile(fileid, dat_offset: LongWord; size: LongWord; target: Pointer);
|
---|
44 | virtual; abstract;
|
---|
45 | procedure LoadRawFilePart(fileid, dat_offset: LongWord;
|
---|
46 | offset, size: LongWord; target: Pointer); virtual; abstract;
|
---|
47 | procedure UpdateRawFilePart(fileid, dat_offset: LongWord;
|
---|
48 | offset, size: LongWord; target: Pointer); virtual; abstract;
|
---|
49 | function AppendRawFile(loc_sep: Boolean; size: LongWord; target: Pointer): LongWord;
|
---|
50 | virtual; abstract;//Returns new Address
|
---|
51 | published
|
---|
52 | end;
|
---|
53 |
|
---|
54 | TOniDataDat = class(TOniData)
|
---|
55 | private
|
---|
56 | Fdat_file: TFileStream;
|
---|
57 | Fraw_file: TFileStream;
|
---|
58 | Fsep_file: TFileStream;
|
---|
59 | Fdat_header: THeader;
|
---|
60 | Fdat_filesmap: TFilesMap;
|
---|
61 | Fdat_files: TFiles;
|
---|
62 | Fdat_namedfilesmap: TNamedFilesMap;
|
---|
63 | Fdat_extensionsmap: TExtensionsMap;
|
---|
64 | FUnloadWhenUnused: Boolean;
|
---|
65 | FDatOpened: Boolean;
|
---|
66 | FRawOpened: Boolean;
|
---|
67 | FSepOpened: Boolean;
|
---|
68 | protected
|
---|
69 | public
|
---|
70 | property UnloadWhenUnused: Boolean Read FUnloadWhenUnused Write FUnloadWhenUnused;
|
---|
71 |
|
---|
72 | constructor Create(DatFilename: String; var Result: Boolean); override;
|
---|
73 | procedure Close; override;
|
---|
74 |
|
---|
75 | function GetFileInfo(fileid: Integer): TFileInfo; override;
|
---|
76 | function GetFilesList(ext: String; pattern: String;
|
---|
77 | NoEmptyFiles: Boolean; sort: TSortType): TStringArray; override;
|
---|
78 | function GetFilesCount: LongWord; override;
|
---|
79 | function GetExtensionsList: TStringArray; override;
|
---|
80 | function GetExtendedExtensionsList: TExtensionsMap; override;
|
---|
81 |
|
---|
82 | function LoadDatFile(fileid: LongWord): Tdata; override;
|
---|
83 | procedure UpdateDatFile(fileid: LongWord; Data: Tdata); override;
|
---|
84 | procedure LoadDatFilePart(fileid, offset, size: LongWord; target: Pointer); override;
|
---|
85 | procedure UpdateDatFilePart(fileid, offset, size: LongWord; target: Pointer); override;
|
---|
86 |
|
---|
87 | procedure LoadRawOffset(loc_sep: Boolean; raw_addr, size: LongWord; target: Pointer);
|
---|
88 | function GetRawList(fileid: LongWord): TRawList; override;
|
---|
89 | procedure LoadRawFile(fileid, dat_offset: LongWord; target: Pointer); override;
|
---|
90 | procedure UpdateRawFile(fileid, dat_offset: LongWord; size: LongWord;
|
---|
91 | target: Pointer); override;
|
---|
92 | procedure LoadRawFilePart(fileid, dat_offset: LongWord;
|
---|
93 | offset, size: LongWord; target: Pointer); override;
|
---|
94 | procedure UpdateRawFilePart(fileid, dat_offset: LongWord;
|
---|
95 | offset, size: LongWord; target: Pointer); override;
|
---|
96 | function AppendRawFile(loc_sep: Boolean; size: LongWord; target: Pointer): LongWord;
|
---|
97 | override;//Returns new Address
|
---|
98 | published
|
---|
99 | end;
|
---|
100 |
|
---|
101 | TOniDataADB = class(TOniData)
|
---|
102 | private
|
---|
103 | FDatabase: TABSDatabase;
|
---|
104 | FQuery: TABSQuery;
|
---|
105 | Fdat_files: TFiles;
|
---|
106 | Fdat_extensionsmap: TExtensionsMap;
|
---|
107 | protected
|
---|
108 | public
|
---|
109 | constructor Create(OLDBFilename: String; var Result: Boolean); override;
|
---|
110 | procedure Close; override;
|
---|
111 |
|
---|
112 | procedure UpdateListCache;
|
---|
113 | // function GetDatLinks(srcid:LongWord):TDatLinks;
|
---|
114 | function GetFileInfo(fileid: Integer): TFileInfo; override;
|
---|
115 | function GetFilesList(ext: String; pattern: String;
|
---|
116 | NoEmptyFiles: Boolean; sort: TSortType): TStringArray; override;
|
---|
117 | function GetFilesCount: LongWord; override;
|
---|
118 | function GetExtensionsList: TStringArray; override;
|
---|
119 | function GetExtendedExtensionsList: TExtensionsMap; override;
|
---|
120 | function GetNamedFilesMap: TNamedFilesMap;
|
---|
121 |
|
---|
122 | function LoadDatFile(fileid: LongWord): Tdata; override;
|
---|
123 | procedure UpdateDatFile(fileid: LongWord; Data: Tdata); override;
|
---|
124 | procedure LoadDatFilePart(fileid, offset, size: LongWord; target: Pointer); override;
|
---|
125 | procedure UpdateDatFilePart(fileid, offset, size: LongWord; target: Pointer); override;
|
---|
126 |
|
---|
127 | function GetRawList(fileid: LongWord): TRawList; override;
|
---|
128 | procedure LoadRawFile(fileid, dat_offset: LongWord; target: Pointer); override;
|
---|
129 | procedure UpdateRawFile(fileid, dat_offset: LongWord; size: LongWord;
|
---|
130 | target: Pointer); override;
|
---|
131 | procedure LoadRawFilePart(fileid, dat_offset: LongWord;
|
---|
132 | offset, size: LongWord; target: Pointer); override;
|
---|
133 | procedure UpdateRawFilePart(fileid, dat_offset: LongWord;
|
---|
134 | offset, size: LongWord; target: Pointer); override;
|
---|
135 | published
|
---|
136 | end;
|
---|
137 |
|
---|
138 | TOniDataEmpty = class(TOniData)
|
---|
139 | private
|
---|
140 | protected
|
---|
141 | public
|
---|
142 | constructor Create(OLDBFilename: String; var Result: Boolean); override;
|
---|
143 | procedure Close; override;
|
---|
144 | published
|
---|
145 | end;
|
---|
146 |
|
---|
147 | const
|
---|
148 | ODB_None = -1;
|
---|
149 | ODB_Dat = 0;
|
---|
150 | ODB_ADB = 1;
|
---|
151 |
|
---|
152 | var
|
---|
153 | // OniDataConnection: TOniData;
|
---|
154 | DataConnections: array of TOniData;
|
---|
155 | OniDataConnection: TOniData;
|
---|
156 |
|
---|
157 | function CreateDataConnection(filename: String; backend: Integer): TOniData;
|
---|
158 | procedure CloseDataConnection(connection: TOniData);
|
---|
159 | function GetEmptyFileInfo: TFileInfo;
|
---|
160 |
|
---|
161 |
|
---|
162 |
|
---|
163 |
|
---|
164 |
|
---|
165 | implementation
|
---|
166 | uses DataStructures, Functions;
|
---|
167 |
|
---|
168 |
|
---|
169 |
|
---|
170 | (*
|
---|
171 | Implementation of TOniData
|
---|
172 | *)
|
---|
173 |
|
---|
174 | function TOniData.GetFileIDByName(Name: String): Integer;
|
---|
175 | var
|
---|
176 | files: TStringArray;
|
---|
177 | i: Integer;
|
---|
178 | begin
|
---|
179 | Result := -1;
|
---|
180 | files := Self.GetFilesList('', Name, False, stIDAsc);
|
---|
181 | if Length(files) > 0 then
|
---|
182 | for i := 0 to High(files) do
|
---|
183 | if Pos(Name, files[i]) = Pos('-', files[i]) + 1 then
|
---|
184 | begin
|
---|
185 | // if MidStr(files[i],Pos('-',files[i])+1,Length(files[i])-Pos('-',files[i])-5)=name then begin
|
---|
186 | Result := Self.ExtractFileID(files[i]);
|
---|
187 | Break;
|
---|
188 | end;
|
---|
189 | end;
|
---|
190 |
|
---|
191 |
|
---|
192 |
|
---|
193 |
|
---|
194 | function TOniData.ExtractFileID(Name: String): Integer;
|
---|
195 | begin
|
---|
196 | if Name[5] = '-' then
|
---|
197 | Result := HexToLong(MidStr(Name, 1, 4))
|
---|
198 | else
|
---|
199 | Result := StrToInt(MidStr(Name, 1, 5));
|
---|
200 | end;
|
---|
201 |
|
---|
202 |
|
---|
203 |
|
---|
204 |
|
---|
205 | function TOniData.GetRawInfo(fileid, dat_offset: LongWord): TRawInfo;
|
---|
206 | var
|
---|
207 | i: LongWord;
|
---|
208 | raw_list: TRawList;
|
---|
209 | begin
|
---|
210 | raw_list := Self.GetRawList(fileid);
|
---|
211 | Result.src_id := 0;
|
---|
212 | Result.src_offset := 0;
|
---|
213 | Result.raw_addr := 0;
|
---|
214 | Result.raw_size := 0;
|
---|
215 | for i := 0 to High(raw_list) do
|
---|
216 | begin
|
---|
217 | if raw_list[i].src_offset = dat_offset then
|
---|
218 | begin
|
---|
219 | Result.src_id := fileid;
|
---|
220 | Result.src_offset := raw_list[i].src_offset;
|
---|
221 | Result.raw_addr := raw_list[i].raw_addr;
|
---|
222 | Result.raw_size := raw_list[i].raw_size;
|
---|
223 | Result.loc_sep := raw_list[i].loc_sep;
|
---|
224 | Break;
|
---|
225 | end;
|
---|
226 | end;
|
---|
227 | end;
|
---|
228 |
|
---|
229 |
|
---|
230 |
|
---|
231 | function TOniData.GetFileInfo(fileid: Integer): TFileInfo;
|
---|
232 | begin
|
---|
233 | Result.ID := -1;
|
---|
234 | Result.FileName := '';
|
---|
235 | Result.FileNameHex := '';
|
---|
236 | Result.Extension := '';
|
---|
237 | Result.Name := '';
|
---|
238 | Result.Size := 0;
|
---|
239 | Result.FileType := 0;
|
---|
240 | Result.DatAddr := 0;
|
---|
241 | Result.opened := False;
|
---|
242 | end;
|
---|
243 |
|
---|
244 |
|
---|
245 |
|
---|
246 |
|
---|
247 | (*
|
---|
248 | ================================================================================
|
---|
249 | Implementation of TOniDataDat
|
---|
250 | *)
|
---|
251 |
|
---|
252 | constructor TOniDataDat.Create(DatFilename: String; var Result: Boolean);
|
---|
253 | const
|
---|
254 | header_ident1_pc: array[0..$13] of Byte =
|
---|
255 | ($1F, $27, $DC, $33, $DF, $BC, $03, $00, $31, $33, $52, $56, $40, $00,
|
---|
256 | $14, $00, $10, $00, $08, $00);
|
---|
257 | header_ident1_mac: array[0..$13] of Byte =
|
---|
258 | ($61, $30, $C1, $23, $DF, $BC, $03, $00, $31, $33, $52, $56, $40, $00,
|
---|
259 | $14, $00, $10, $00, $08, $00);
|
---|
260 | header_ident1_macbeta: array[0..$13] of Byte =
|
---|
261 | ($81, $11, $8D, $23, $DF, $BC, $03, $00, $31, $33, $52, $56, $40, $00,
|
---|
262 | $14, $00, $10, $00, $08, $00);
|
---|
263 | header_ident2: array[0..$F] of Byte =
|
---|
264 | ($99, $CF, $40, $00, $90, $4F, $63, $00, $F4, $55, $5F, $00, $90, $4F, $63, $00);
|
---|
265 | var
|
---|
266 | i: LongWord;
|
---|
267 | header_pc, header_mac: Boolean;
|
---|
268 | begin
|
---|
269 | FUnloadWhenUnused := True;
|
---|
270 | FDatOpened := False;
|
---|
271 | FRawOpened := False;
|
---|
272 | if not FileExists(DatFilename) then
|
---|
273 | begin
|
---|
274 | ShowMessage('File doesn''t exist!!!');
|
---|
275 | Result := False;
|
---|
276 | Exit;
|
---|
277 | end;
|
---|
278 | FFileName := DatFilename;
|
---|
279 | Fdat_file := TFileStream.Create(FFileName, fmOpenRead);
|
---|
280 | Fdat_file.Read(Fdat_header, SizeOf(Fdat_header));
|
---|
281 | header_pc := True;
|
---|
282 | header_mac := True;
|
---|
283 | for i := 0 to High(Fdat_header.Ident) do
|
---|
284 | begin
|
---|
285 | FLevelInfo.Ident[i] := Fdat_header.Ident[i];
|
---|
286 | if Fdat_header.Ident[i] <> header_ident1_pc[i] then
|
---|
287 | header_pc := False;
|
---|
288 | if Fdat_header.Ident[i] <> header_ident1_mac[i] then
|
---|
289 | header_mac := False;
|
---|
290 | end;
|
---|
291 | if not (header_pc xor header_mac) then
|
---|
292 | begin
|
---|
293 | Result := False;
|
---|
294 | Exit;
|
---|
295 | end
|
---|
296 | else
|
---|
297 | begin
|
---|
298 | if (header_pc and not header_mac) then
|
---|
299 | Fos_mac := False
|
---|
300 | else
|
---|
301 | Fos_mac := True;
|
---|
302 | end;
|
---|
303 | SetLength(Fdat_filesmap, Fdat_header.Files);
|
---|
304 | SetLength(Fdat_files, Fdat_header.Files);
|
---|
305 | for i := 0 to Fdat_header.Files - 1 do
|
---|
306 | Fdat_file.Read(Fdat_filesmap[i], SizeOf(Fdat_filesmap[i]));
|
---|
307 | for i := 0 to Fdat_header.Files - 1 do
|
---|
308 | begin
|
---|
309 | Fdat_files[i].ID := i;
|
---|
310 | Fdat_files[i].Extension := Fdat_filesmap[i].Extension;
|
---|
311 | Fdat_files[i].Extension := ReverseString(Fdat_files[i].Extension);
|
---|
312 | Fdat_files[i].Size := Fdat_filesmap[i].FileSize;
|
---|
313 | Fdat_files[i].FileType := Fdat_filesmap[i].FileType;
|
---|
314 | Fdat_files[i].DatAddr := Fdat_filesmap[i].DataAddr - 8 + Fdat_header.DataAddr;
|
---|
315 | if (Fdat_filesmap[i].FileType and $01) = 0 then
|
---|
316 | begin
|
---|
317 | Fdat_file.Seek(Fdat_filesmap[i].NameAddr + Fdat_header.NamesAddr, soFromBeginning);
|
---|
318 | SetLength(Fdat_files[i].Name, 100);
|
---|
319 | Fdat_file.Read(Fdat_files[i].Name[1], 100);
|
---|
320 | Fdat_files[i].Name := MidStr(Fdat_files[i].Name, 1 + 4, Pos(
|
---|
321 | #0, Fdat_files[i].Name) - 1 - 4);
|
---|
322 | end
|
---|
323 | else
|
---|
324 | begin
|
---|
325 | Fdat_files[i].Name := '';
|
---|
326 | end;
|
---|
327 | Fdat_files[i].FileName :=
|
---|
328 | FormatNumber(i, 5, '0') + '-' + Fdat_files[i].Name + '.' + Fdat_files[i].Extension;
|
---|
329 | Fdat_files[i].FileNameHex :=
|
---|
330 | IntToHex(i, 4) + '-' + Fdat_files[i].Name + '.' + Fdat_files[i].Extension;
|
---|
331 | end;
|
---|
332 | Fdat_file.Seek($40 + Fdat_header.Files * $14, soFromBeginning);
|
---|
333 | SetLength(Fdat_namedfilesmap, Fdat_header.NamedFiles);
|
---|
334 | for i := 0 to Fdat_header.NamedFiles - 1 do
|
---|
335 | Fdat_file.Read(Fdat_namedfilesmap[i], SizeOf(Fdat_namedfilesmap[i]));
|
---|
336 |
|
---|
337 | Fdat_file.Seek($40 + Fdat_header.Files * $14 + Fdat_header.NamedFiles * $8, soFromBeginning);
|
---|
338 | SetLength(Fdat_extensionsmap, Fdat_header.Extensions);
|
---|
339 | for i := 0 to Fdat_header.Extensions - 1 do
|
---|
340 | Fdat_file.Read(Fdat_extensionsmap[i], SizeOf(Fdat_extensionsmap[i]));
|
---|
341 |
|
---|
342 | Fdat_file.Seek(Fdat_files[0].DatAddr + 7, soFromBeginning);
|
---|
343 | Fdat_file.Read(FLevelInfo.LevelNumber, 1);
|
---|
344 | FLevelInfo.LevelNumber := FLevelInfo.LevelNumber div 2;
|
---|
345 |
|
---|
346 | Fdat_file.Free;
|
---|
347 |
|
---|
348 | Result := True;
|
---|
349 | FBackend := ODB_Dat;
|
---|
350 | end;
|
---|
351 |
|
---|
352 |
|
---|
353 |
|
---|
354 |
|
---|
355 | procedure TOniDataDat.Close;
|
---|
356 | begin
|
---|
357 | if not FUnloadWhenUnused and FDatOpened then
|
---|
358 | Fdat_file.Free;
|
---|
359 | if not FUnloadWhenUnused and FRawOpened then
|
---|
360 | Fraw_file.Free;
|
---|
361 | if not FUnloadWhenUnused and FSepOpened then
|
---|
362 | Fsep_file.Free;
|
---|
363 | Self.Free;
|
---|
364 | end;
|
---|
365 |
|
---|
366 |
|
---|
367 |
|
---|
368 |
|
---|
369 | function TOniDataDat.GetFileInfo(fileid: Integer): TFileInfo;
|
---|
370 | begin
|
---|
371 | if fileid = -1 then
|
---|
372 | begin
|
---|
373 | Result := inherited GetFileInfo(fileid);
|
---|
374 | Exit;
|
---|
375 | end;
|
---|
376 | if fileid < Self.GetFilesCount then
|
---|
377 | Result := Fdat_files[fileid]
|
---|
378 | else
|
---|
379 | Result.ID := -1;
|
---|
380 | end;
|
---|
381 |
|
---|
382 |
|
---|
383 |
|
---|
384 |
|
---|
385 | function TOniDataDat.GetFilesList(ext: String; pattern: String;
|
---|
386 | NoEmptyFiles: Boolean; sort: TSortType): TStringArray;
|
---|
387 | var
|
---|
388 | i: LongWord;
|
---|
389 | list: TStringList;
|
---|
390 | id, name, extension: String;
|
---|
391 | fields: TStrings;
|
---|
392 |
|
---|
393 | procedure getfields;
|
---|
394 | begin
|
---|
395 | fields.CommaText := StringReplace(AnsiQuotedStr(list.Strings[i], '"'), ';', '","', [rfReplaceAll]);
|
---|
396 | if sort in [stIDAsc, stIDDesc] then
|
---|
397 | begin
|
---|
398 | id := fields.Strings[0];
|
---|
399 | name := fields.Strings[1];
|
---|
400 | extension := fields.Strings[2];
|
---|
401 | end;
|
---|
402 | if sort in [stNameAsc, stNameDesc] then
|
---|
403 | begin
|
---|
404 | id := fields.Strings[1];
|
---|
405 | name := fields.Strings[0];
|
---|
406 | extension := fields.Strings[2];
|
---|
407 | end;
|
---|
408 | if sort in [stExtAsc, stExtDesc] then
|
---|
409 | begin
|
---|
410 | id := fields.Strings[1];
|
---|
411 | name := fields.Strings[2];
|
---|
412 | extension := fields.Strings[0];
|
---|
413 | end;
|
---|
414 | end;
|
---|
415 |
|
---|
416 | begin
|
---|
417 | list := TStringList.Create;
|
---|
418 | list.Sorted := True;
|
---|
419 | for i := 0 to Fdat_header.Files - 1 do
|
---|
420 | begin
|
---|
421 | if ((Length(ext) = 0) or (Pos(Fdat_files[i].Extension, ext) > 0)) and
|
---|
422 | ((Length(pattern) = 0) or
|
---|
423 | (Pos(UpperCase(pattern), UpperCase(Fdat_files[i].Name)) > 0)) then
|
---|
424 | begin
|
---|
425 | if (NoEmptyFiles = False) or ((Fdat_files[i].FileType and $02) = 0) then
|
---|
426 | begin
|
---|
427 | if AppSettings.FilenumbersAsHex then
|
---|
428 | id := IntToHex(Fdat_files[i].ID, 4)
|
---|
429 | else
|
---|
430 | id := FormatNumber(Fdat_files[i].ID, 5, '0');
|
---|
431 | name := Fdat_files[i].Name;
|
---|
432 | extension := Fdat_files[i].Extension;
|
---|
433 |
|
---|
434 | case sort of
|
---|
435 | stIDAsc, stIDDesc: list.Add(id + ';' + name + ';' + extension);
|
---|
436 | stNameAsc, stNameDesc: list.Add(name + ';' + id + ';' + extension);
|
---|
437 | stExtAsc, stExtDesc: list.Add(extension + ';' + id + ';' + name);
|
---|
438 | end;
|
---|
439 | end;
|
---|
440 | end;
|
---|
441 | end;
|
---|
442 | SetLength(Result, list.Count);
|
---|
443 | if Length(Result) > 0 then
|
---|
444 | begin
|
---|
445 | fields := TStringList.Create;
|
---|
446 | if sort in [stIDAsc, stNameAsc, stExtAsc] then
|
---|
447 | for i := 0 to list.Count - 1 do
|
---|
448 | begin
|
---|
449 | getfields;
|
---|
450 | Result[i] := id + '-' + name + '.' + extension;
|
---|
451 | end
|
---|
452 | else
|
---|
453 | for i := list.Count - 1 downto 0 do
|
---|
454 | begin
|
---|
455 | getfields;
|
---|
456 | Result[list.Count - i - 1] := id + '-' + name + '.' + extension;
|
---|
457 | end;
|
---|
458 | fields.Free;
|
---|
459 | end;
|
---|
460 | list.Free;
|
---|
461 | end;
|
---|
462 |
|
---|
463 |
|
---|
464 |
|
---|
465 |
|
---|
466 | function TOniDataDat.GetFilesCount: LongWord;
|
---|
467 | begin
|
---|
468 | Result := Fdat_header.Files;
|
---|
469 | end;
|
---|
470 |
|
---|
471 |
|
---|
472 |
|
---|
473 |
|
---|
474 | function TOniDataDat.GetExtensionsList: TStringArray;
|
---|
475 | var
|
---|
476 | i: LongWord;
|
---|
477 | begin
|
---|
478 | SetLength(Result, Fdat_header.Extensions);
|
---|
479 | for i := 0 to Fdat_header.Extensions - 1 do
|
---|
480 | begin
|
---|
481 | with Fdat_extensionsmap[i] do
|
---|
482 | begin
|
---|
483 | Result[i] := Extension[3] + Extension[2] + Extension[1] + Extension[0] +
|
---|
484 | ' (' + IntToStr(ExtCount) + ')';
|
---|
485 | end;
|
---|
486 | end;
|
---|
487 | end;
|
---|
488 |
|
---|
489 |
|
---|
490 |
|
---|
491 |
|
---|
492 | function TOniDataDat.GetExtendedExtensionsList: TExtensionsMap;
|
---|
493 | var
|
---|
494 | i: LongWord;
|
---|
495 | begin
|
---|
496 | SetLength(Result, Fdat_header.Extensions);
|
---|
497 | for i := 0 to Fdat_header.Extensions - 1 do
|
---|
498 | begin
|
---|
499 | Result[i] := Fdat_extensionsmap[i];
|
---|
500 | end;
|
---|
501 | end;
|
---|
502 |
|
---|
503 |
|
---|
504 |
|
---|
505 |
|
---|
506 | function TOniDataDat.LoadDatFile(fileid: LongWord): Tdata;
|
---|
507 | begin
|
---|
508 | if fileid < Self.GetFilesCount then
|
---|
509 | begin
|
---|
510 | if FUnloadWhenUnused or not FDatOpened then
|
---|
511 | Fdat_file := TFileStream.Create(FFileName, fmOpenReadWrite);
|
---|
512 | Fdat_file.Seek(Fdat_files[fileid].DatAddr, soFromBeginning);
|
---|
513 | SetLength(Result, Fdat_files[fileid].Size);
|
---|
514 | Fdat_file.Read(Result[0], Fdat_files[fileid].Size);
|
---|
515 | if UnloadWhenUnused then
|
---|
516 | Fdat_file.Free
|
---|
517 | else
|
---|
518 | FDatOpened := True;
|
---|
519 | end;
|
---|
520 | end;
|
---|
521 |
|
---|
522 |
|
---|
523 |
|
---|
524 |
|
---|
525 | procedure TOniDataDat.UpdateDatFile(fileid: LongWord; Data: Tdata);
|
---|
526 | begin
|
---|
527 | if fileid < Self.GetFilesCount then
|
---|
528 | begin
|
---|
529 | if FUnloadWhenUnused or not FDatOpened then
|
---|
530 | Fdat_file := TFileStream.Create(FFileName, fmOpenReadWrite);
|
---|
531 | Fdat_file.Seek(Fdat_files[fileid].DatAddr, soFromBeginning);
|
---|
532 | Fdat_file.Write(Data[0], Length(Data));
|
---|
533 | if UnloadWhenUnused then
|
---|
534 | Fdat_file.Free
|
---|
535 | else
|
---|
536 | FDatOpened := True;
|
---|
537 | end;
|
---|
538 | end;
|
---|
539 |
|
---|
540 |
|
---|
541 |
|
---|
542 |
|
---|
543 | procedure TOniDataDat.LoadDatFilePart(fileid, offset, size: LongWord; target: Pointer);
|
---|
544 | begin
|
---|
545 | if fileid < Self.GetFilesCount then
|
---|
546 | begin
|
---|
547 | if FUnloadWhenUnused or not FDatOpened then
|
---|
548 | Fdat_file := TFileStream.Create(FFileName, fmOpenReadWrite);
|
---|
549 | Fdat_file.Seek(Fdat_files[fileid].DatAddr + offset, soFromBeginning);
|
---|
550 | Fdat_file.Read(target^, size);
|
---|
551 | if UnloadWhenUnused then
|
---|
552 | Fdat_file.Free
|
---|
553 | else
|
---|
554 | FDatOpened := True;
|
---|
555 | end;
|
---|
556 | end;
|
---|
557 |
|
---|
558 |
|
---|
559 |
|
---|
560 |
|
---|
561 | procedure TOniDataDat.UpdateDatFilePart(fileid, offset, size: LongWord; target: Pointer);
|
---|
562 | begin
|
---|
563 | if fileid < Self.GetFilesCount then
|
---|
564 | begin
|
---|
565 | if FUnloadWhenUnused or not FDatOpened then
|
---|
566 | Fdat_file := TFileStream.Create(FFileName, fmOpenReadWrite);
|
---|
567 | Fdat_file.Seek(Fdat_files[fileid].DatAddr + offset, soFromBeginning);
|
---|
568 | Fdat_file.Write(target^, size);
|
---|
569 | if UnloadWhenUnused then
|
---|
570 | Fdat_file.Free
|
---|
571 | else
|
---|
572 | FDatOpened := True;
|
---|
573 | end;
|
---|
574 | end;
|
---|
575 |
|
---|
576 |
|
---|
577 |
|
---|
578 |
|
---|
579 | function TOniDataDat.GetRawList(fileid: LongWord): TRawList;
|
---|
580 | var
|
---|
581 | i: LongWord;
|
---|
582 | begin
|
---|
583 | SetLength(Result, 0);
|
---|
584 | for i := 0 to High(RawListHandlers) do
|
---|
585 | if UpperCase(RawListHandlers[i].Ext) = UpperCase(Fdat_files[fileid].extension) then
|
---|
586 | if RawListHandlers[i].needed then
|
---|
587 | begin
|
---|
588 | Result := RawListHandlers[i].Handler(Self, fileid);
|
---|
589 | Break;
|
---|
590 | end
|
---|
591 | else
|
---|
592 | Break;
|
---|
593 | end;
|
---|
594 |
|
---|
595 |
|
---|
596 |
|
---|
597 |
|
---|
598 | procedure TOniDataDat.LoadRawOffset(loc_sep: Boolean; raw_addr, size: LongWord;
|
---|
599 | target: Pointer);
|
---|
600 | begin
|
---|
601 | if not loc_sep then
|
---|
602 | begin
|
---|
603 | if FUnloadWhenUnused or not FRawOpened then
|
---|
604 | Fraw_file := TFileStream.Create(AnsiReplaceStr(FFileName, '.dat', '.raw'),
|
---|
605 | fmOpenReadWrite);
|
---|
606 | if raw_addr <= Fraw_file.Size then
|
---|
607 | begin
|
---|
608 | Fraw_file.Seek(raw_addr, soFromBeginning);
|
---|
609 | Fraw_file.Read(target^, size);
|
---|
610 | end;
|
---|
611 | if UnloadWhenUnused then
|
---|
612 | Fraw_file.Free
|
---|
613 | else
|
---|
614 | FRawOpened := True;
|
---|
615 | end
|
---|
616 | else
|
---|
617 | begin
|
---|
618 | if FUnloadWhenUnused or not FSepOpened then
|
---|
619 | Fsep_file := TFileStream.Create(AnsiReplaceStr(FFileName, '.dat', '.sep'),
|
---|
620 | fmOpenReadWrite);
|
---|
621 | if raw_addr <= Fsep_file.Size then
|
---|
622 | begin
|
---|
623 | Fsep_file.Seek(raw_addr, soFromBeginning);
|
---|
624 | Fsep_file.Read(target^, size);
|
---|
625 | end;
|
---|
626 | if UnloadWhenUnused then
|
---|
627 | Fsep_file.Free
|
---|
628 | else
|
---|
629 | FSepOpened := True;
|
---|
630 | end;
|
---|
631 | end;
|
---|
632 |
|
---|
633 |
|
---|
634 |
|
---|
635 |
|
---|
636 | procedure TOniDataDat.LoadRawFile(fileid, dat_offset: LongWord; target: Pointer);
|
---|
637 | var
|
---|
638 | raw_info: TRawInfo;
|
---|
639 | begin
|
---|
640 | if fileid < Self.GetFilesCount then
|
---|
641 | begin
|
---|
642 | raw_info := Self.GetRawInfo(fileid, dat_offset);
|
---|
643 | if not raw_info.loc_sep then
|
---|
644 | begin
|
---|
645 | if FUnloadWhenUnused or not FRawOpened then
|
---|
646 | Fraw_file := TFileStream.Create(AnsiReplaceStr(FFileName, '.dat', '.raw'),
|
---|
647 | fmOpenReadWrite);
|
---|
648 | Fraw_file.Seek(raw_info.raw_addr, soFromBeginning);
|
---|
649 | Fraw_file.Read(target^, raw_info.raw_size);
|
---|
650 | if UnloadWhenUnused then
|
---|
651 | Fraw_file.Free
|
---|
652 | else
|
---|
653 | FRawOpened := True;
|
---|
654 | end
|
---|
655 | else
|
---|
656 | begin
|
---|
657 | if FUnloadWhenUnused or not FSepOpened then
|
---|
658 | Fsep_file := TFileStream.Create(AnsiReplaceStr(FFileName, '.dat', '.sep'),
|
---|
659 | fmOpenReadWrite);
|
---|
660 | Fsep_file.Seek(raw_info.raw_addr, soFromBeginning);
|
---|
661 | Fsep_file.Read(target^, raw_info.raw_size);
|
---|
662 | if UnloadWhenUnused then
|
---|
663 | Fsep_file.Free
|
---|
664 | else
|
---|
665 | FSepOpened := True;
|
---|
666 | end;
|
---|
667 | end;
|
---|
668 | end;
|
---|
669 |
|
---|
670 |
|
---|
671 |
|
---|
672 |
|
---|
673 | procedure TOniDataDat.UpdateRawFile(fileid, dat_offset: LongWord;
|
---|
674 | size: LongWord; target: Pointer);
|
---|
675 | var
|
---|
676 | raw_info: TRawInfo;
|
---|
677 | begin
|
---|
678 | if fileid < Self.GetFilesCount then
|
---|
679 | begin
|
---|
680 | raw_info := Self.GetRawInfo(fileid, dat_offset);
|
---|
681 | if not raw_info.loc_sep then
|
---|
682 | begin
|
---|
683 | if FUnloadWhenUnused or not FRawOpened then
|
---|
684 | Fraw_file := TFileStream.Create(AnsiReplaceStr(FFileName, '.dat', '.raw'),
|
---|
685 | fmOpenReadWrite);
|
---|
686 | Fraw_file.Seek(raw_info.raw_addr, soFromBeginning);
|
---|
687 | Fraw_file.Write(target^, raw_info.raw_size);
|
---|
688 | if UnloadWhenUnused then
|
---|
689 | Fraw_file.Free
|
---|
690 | else
|
---|
691 | FRawOpened := True;
|
---|
692 | end
|
---|
693 | else
|
---|
694 | begin
|
---|
695 | if FUnloadWhenUnused or not FSepOpened then
|
---|
696 | Fsep_file := TFileStream.Create(AnsiReplaceStr(FFileName, '.dat', '.sep'),
|
---|
697 | fmOpenReadWrite);
|
---|
698 | Fsep_file.Seek(raw_info.raw_addr, soFromBeginning);
|
---|
699 | Fsep_file.Write(target^, raw_info.raw_size);
|
---|
700 | if UnloadWhenUnused then
|
---|
701 | Fsep_file.Free
|
---|
702 | else
|
---|
703 | FSepOpened := True;
|
---|
704 | end;
|
---|
705 | end;
|
---|
706 | end;
|
---|
707 |
|
---|
708 |
|
---|
709 |
|
---|
710 |
|
---|
711 | procedure TOniDataDat.LoadRawFilePart(fileid, dat_offset: LongWord;
|
---|
712 | offset, size: LongWord; target: Pointer);
|
---|
713 | var
|
---|
714 | raw_info: TRawInfo;
|
---|
715 | Data: Tdata;
|
---|
716 | mem: TMemoryStream;
|
---|
717 | begin
|
---|
718 | if fileid < Self.GetFilesCount then
|
---|
719 | begin
|
---|
720 | raw_info := Self.GetRawInfo(fileid, dat_offset);
|
---|
721 | SetLength(Data, raw_info.raw_size);
|
---|
722 | Self.LoadRawFile(fileid, dat_offset, @Data[0]);
|
---|
723 | mem := TMemoryStream.Create;
|
---|
724 | mem.Write(Data[offset], size);
|
---|
725 | mem.Read(target^, size);
|
---|
726 | mem.Free;
|
---|
727 | end;
|
---|
728 | end;
|
---|
729 |
|
---|
730 |
|
---|
731 |
|
---|
732 |
|
---|
733 | procedure TOniDataDat.UpdateRawFilePart(fileid, dat_offset: LongWord;
|
---|
734 | offset, size: LongWord; target: Pointer);
|
---|
735 | var
|
---|
736 | raw_info: TRawInfo;
|
---|
737 | begin
|
---|
738 | if fileid < Self.GetFilesCount then
|
---|
739 | begin
|
---|
740 | raw_info := Self.GetRawInfo(fileid, dat_offset);
|
---|
741 | if not raw_info.loc_sep then
|
---|
742 | begin
|
---|
743 | if FUnloadWhenUnused or not FRawOpened then
|
---|
744 | Fraw_file := TFileStream.Create(AnsiReplaceStr(FFileName, '.dat', '.raw'),
|
---|
745 | fmOpenReadWrite);
|
---|
746 | Fraw_file.Seek(raw_info.raw_addr + offset, soFromBeginning);
|
---|
747 | Fraw_file.Write(target^, raw_info.raw_size);
|
---|
748 | if UnloadWhenUnused then
|
---|
749 | Fraw_file.Free
|
---|
750 | else
|
---|
751 | FRawOpened := True;
|
---|
752 | end
|
---|
753 | else
|
---|
754 | begin
|
---|
755 | if FUnloadWhenUnused or not FSepOpened then
|
---|
756 | Fsep_file := TFileStream.Create(AnsiReplaceStr(FFileName, '.dat', '.sep'),
|
---|
757 | fmOpenReadWrite);
|
---|
758 | Fsep_file.Seek(raw_info.raw_addr + offset, soFromBeginning);
|
---|
759 | Fsep_file.Write(target^, raw_info.raw_size);
|
---|
760 | if UnloadWhenUnused then
|
---|
761 | Fsep_file.Free
|
---|
762 | else
|
---|
763 | FSepOpened := True;
|
---|
764 | end;
|
---|
765 | end;
|
---|
766 | end;
|
---|
767 |
|
---|
768 |
|
---|
769 |
|
---|
770 |
|
---|
771 | function TOniDataDat.AppendRawFile(loc_sep: Boolean; size: LongWord;
|
---|
772 | target: Pointer): LongWord; //Returns new Address
|
---|
773 | begin
|
---|
774 | if not loc_sep then
|
---|
775 | begin
|
---|
776 | if FUnloadWhenUnused or not FRawOpened then
|
---|
777 | Fraw_file := TFileStream.Create(AnsiReplaceStr(FFileName, '.dat', '.raw'),
|
---|
778 | fmOpenReadWrite);
|
---|
779 | Result := Fraw_file.Size;
|
---|
780 | Fraw_file.Seek(0, soFromEnd);
|
---|
781 | Fraw_file.Write(target^, size);
|
---|
782 | if UnloadWhenUnused then
|
---|
783 | Fraw_file.Free
|
---|
784 | else
|
---|
785 | FRawOpened := True;
|
---|
786 | end
|
---|
787 | else
|
---|
788 | begin
|
---|
789 | if FUnloadWhenUnused or not FSepOpened then
|
---|
790 | Fsep_file := TFileStream.Create(AnsiReplaceStr(FFileName, '.dat', '.sep'),
|
---|
791 | fmOpenReadWrite);
|
---|
792 | Result := Fsep_file.Size;
|
---|
793 | Fsep_file.Seek(0, soFromEnd);
|
---|
794 | Fsep_file.Write(target^, size);
|
---|
795 | if UnloadWhenUnused then
|
---|
796 | Fsep_file.Free
|
---|
797 | else
|
---|
798 | FSepOpened := True;
|
---|
799 | end;
|
---|
800 | end;
|
---|
801 |
|
---|
802 |
|
---|
803 |
|
---|
804 |
|
---|
805 |
|
---|
806 |
|
---|
807 |
|
---|
808 |
|
---|
809 |
|
---|
810 |
|
---|
811 |
|
---|
812 | (*
|
---|
813 | ================================================================================
|
---|
814 | Implementation of TOniDataADB
|
---|
815 | *)
|
---|
816 |
|
---|
817 | constructor TOniDataADB.Create(OLDBFilename: String; var Result: Boolean);
|
---|
818 | var
|
---|
819 | i, j: Byte;
|
---|
820 | temps: String;
|
---|
821 | begin
|
---|
822 | if not FileExists(OLDBFilename) then
|
---|
823 | begin
|
---|
824 | ShowMessage('File doesn''t exist!!!');
|
---|
825 | Result := False;
|
---|
826 | Exit;
|
---|
827 | end;
|
---|
828 | FFileName := OLDBFilename;
|
---|
829 | FDatabase := TABSDatabase.Create(nil);
|
---|
830 | FDatabase.DatabaseName := 'OLDBcon';
|
---|
831 | FDatabase.DatabaseFileName := OLDBFilename;
|
---|
832 | FDatabase.Open;
|
---|
833 | FQuery := TABSQuery.Create(FDatabase);
|
---|
834 | FQuery.DatabaseName := 'OLDBcon';
|
---|
835 | FQuery.SQL.Text := 'SELECT [name],[value] FROM globals ORDER BY [name] ASC';
|
---|
836 | FQuery.Open;
|
---|
837 | FQuery.First;
|
---|
838 | repeat
|
---|
839 | if FQuery.FieldByName('name').AsString = 'dbversion' then
|
---|
840 | begin
|
---|
841 | if FQuery.FieldByName('value').AsString <> DBversion then
|
---|
842 | begin
|
---|
843 | ShowMessage('Database-file ' + #13 + #10 +
|
---|
844 | '"' + OLDBFilename + '"' + #13 + #10 +
|
---|
845 | 'has wrong version. (Required: ' + DBversion + '; found: ' +
|
---|
846 | FQuery.FieldByName('value').AsString + ')');
|
---|
847 | FQuery.Close;
|
---|
848 | Result := False;
|
---|
849 | Exit;
|
---|
850 | end;
|
---|
851 | end;
|
---|
852 | if FQuery.FieldByName('name').AsString = 'lvl' then
|
---|
853 | begin
|
---|
854 | FLevelInfo.LevelNumber := StrToInt(FQuery.FieldByName('value').AsString);
|
---|
855 | end;
|
---|
856 | if FQuery.FieldByName('name').AsString = 'ident' then
|
---|
857 | begin
|
---|
858 | temps := FQuery.FieldByName('value').AsString;
|
---|
859 | for i := 0 to High(FLevelInfo.Ident) do
|
---|
860 | begin
|
---|
861 | j := i * 2 + 1;
|
---|
862 | case temps[j] of
|
---|
863 | '0'..'9':
|
---|
864 | FLevelInfo.Ident[i] := Ord(temps[j]) - 48;
|
---|
865 | 'A'..'F':
|
---|
866 | FLevelInfo.Ident[i] := Ord(temps[j]) - 55;
|
---|
867 | end;
|
---|
868 | FLevelInfo.Ident[i] := FLevelInfo.Ident[i] * 16;
|
---|
869 | case temps[j + 1] of
|
---|
870 | '0'..'9':
|
---|
871 | FLevelInfo.Ident[i] := FLevelInfo.Ident[i] + Ord(temps[j + 1]) - 48;
|
---|
872 | 'A'..'F':
|
---|
873 | FLevelInfo.Ident[i] := FLevelInfo.Ident[i] + Ord(temps[j + 1]) - 55;
|
---|
874 | end;
|
---|
875 | end;
|
---|
876 | end;
|
---|
877 | if FQuery.FieldByName('name').AsString = 'ident' then
|
---|
878 | begin
|
---|
879 | temps := FQuery.FieldByName('value').AsString;
|
---|
880 | Fos_mac := temps = 'MAC';
|
---|
881 | end;
|
---|
882 | FQuery.Next;
|
---|
883 | until FQuery.EOF;
|
---|
884 | FQuery.Close;
|
---|
885 |
|
---|
886 | UpdateListCache;
|
---|
887 |
|
---|
888 | Result := True;
|
---|
889 | FBackend := ODB_ADB;
|
---|
890 | end;
|
---|
891 |
|
---|
892 |
|
---|
893 |
|
---|
894 |
|
---|
895 | procedure TOniDataADB.Close;
|
---|
896 | begin
|
---|
897 | FDatabase.Close;
|
---|
898 | FDatabase.Free;
|
---|
899 | Self.Free;
|
---|
900 | end;
|
---|
901 |
|
---|
902 |
|
---|
903 |
|
---|
904 | procedure TOniDataADB.UpdateListCache;
|
---|
905 | var
|
---|
906 | i: LongWord;
|
---|
907 | temps: String;
|
---|
908 | begin
|
---|
909 | FQuery.SQL.Text := 'SELECT id,name,extension,[size],contenttype FROM datfiles ORDER BY id ASC;';
|
---|
910 | FQuery.Open;
|
---|
911 | if FQuery.RecordCount > 0 then
|
---|
912 | begin
|
---|
913 | FQuery.First;
|
---|
914 | SetLength(Fdat_files, FQuery.RecordCount);
|
---|
915 | i := 0;
|
---|
916 | repeat
|
---|
917 | Fdat_files[i].ID := FQuery.FieldByName('id').AsInteger;
|
---|
918 | Fdat_files[i].Name := FQuery.FieldByName('name').AsString;
|
---|
919 | Fdat_files[i].Extension := FQuery.FieldByName('extension').AsString;
|
---|
920 | Fdat_files[i].FileName := FormatNumber(Fdat_files[i].ID, 5, '0') + '-' +
|
---|
921 | Fdat_files[i].Name + '.' + Fdat_files[0].Extension;
|
---|
922 | Fdat_files[i].FileNameHex := IntToHex(Fdat_files[i].ID, 4) + '-' +
|
---|
923 | Fdat_files[i].Name + '.' + Fdat_files[0].Extension;
|
---|
924 | Fdat_files[i].Size := FQuery.FieldByName('size').AsInteger;
|
---|
925 | Fdat_files[i].FileType := HexToLong(FQuery.FieldByName('contenttype').AsString);
|
---|
926 | Fdat_files[i].DatAddr := 0;
|
---|
927 | Fdat_files[i].opened := False;
|
---|
928 | Inc(i);
|
---|
929 | FQuery.Next;
|
---|
930 | until FQuery.EOF;
|
---|
931 | end;
|
---|
932 | FQuery.Close;
|
---|
933 |
|
---|
934 | SetLength(Fdat_extensionsmap, 0);
|
---|
935 | FQuery.SQL.Text :=
|
---|
936 | 'SELECT extension,count(extension) AS x FROM datfiles GROUP BY extension ORDER BY extension ASC;';
|
---|
937 | FQuery.Open;
|
---|
938 | if FQuery.RecordCount > 0 then
|
---|
939 | begin
|
---|
940 | SetLength(Fdat_extensionsmap, FQuery.RecordCount);
|
---|
941 | i := 0;
|
---|
942 | repeat
|
---|
943 | temps := FQuery.FieldByName('extension').AsString[1];
|
---|
944 | Fdat_extensionsmap[i].Extension[3] := temps[1];
|
---|
945 | Fdat_extensionsmap[i].Extension[2] := temps[2];
|
---|
946 | Fdat_extensionsmap[i].Extension[1] := temps[3];
|
---|
947 | Fdat_extensionsmap[i].Extension[0] := temps[4];
|
---|
948 | Fdat_extensionsmap[i].ExtCount := FQuery.FieldByName('x').AsInteger;
|
---|
949 | Inc(i);
|
---|
950 | FQuery.Next;
|
---|
951 | until FQuery.EOF;
|
---|
952 | end;
|
---|
953 | FQuery.Close;
|
---|
954 | end;
|
---|
955 |
|
---|
956 |
|
---|
957 | function TOniDataADB.GetFileInfo(fileid: Integer): TFileInfo;
|
---|
958 | var
|
---|
959 | i: Integer;
|
---|
960 | begin
|
---|
961 | if fileid = -1 then
|
---|
962 | begin
|
---|
963 | Result := inherited GetFileInfo(fileid);
|
---|
964 | Exit;
|
---|
965 | end;
|
---|
966 | if fileid < Self.GetFilesCount then
|
---|
967 | begin
|
---|
968 | for i := 0 to High(Fdat_files) do
|
---|
969 | if Fdat_files[i].ID = fileid then
|
---|
970 | Break;
|
---|
971 | if i < Length(Fdat_files) then
|
---|
972 | Result := Fdat_files[i]
|
---|
973 | else
|
---|
974 | Result.ID := -1;
|
---|
975 | end
|
---|
976 | else
|
---|
977 | begin
|
---|
978 | Result.ID := -1;
|
---|
979 | end;
|
---|
980 | end;
|
---|
981 |
|
---|
982 |
|
---|
983 |
|
---|
984 |
|
---|
985 | function TOniDataADB.GetFilesList(ext: String; pattern: String;
|
---|
986 | NoEmptyFiles: Boolean; sort: TSortType): TStringArray;
|
---|
987 | var
|
---|
988 | i: LongWord;
|
---|
989 | list: TStringList;
|
---|
990 | id, name, extension: String;
|
---|
991 | fields: TStrings;
|
---|
992 |
|
---|
993 | procedure getfields;
|
---|
994 | begin
|
---|
995 | fields.CommaText := StringReplace(AnsiQuotedStr(list.Strings[i], '"'), ';', '","', [rfReplaceAll]);
|
---|
996 | if sort in [stIDAsc, stIDDesc] then
|
---|
997 | begin
|
---|
998 | id := fields.Strings[0];
|
---|
999 | name := fields.Strings[1];
|
---|
1000 | extension := fields.Strings[2];
|
---|
1001 | end;
|
---|
1002 | if sort in [stNameAsc, stNameDesc] then
|
---|
1003 | begin
|
---|
1004 | id := fields.Strings[1];
|
---|
1005 | name := fields.Strings[0];
|
---|
1006 | extension := fields.Strings[2];
|
---|
1007 | end;
|
---|
1008 | if sort in [stExtAsc, stExtDesc] then
|
---|
1009 | begin
|
---|
1010 | id := fields.Strings[1];
|
---|
1011 | name := fields.Strings[2];
|
---|
1012 | extension := fields.Strings[0];
|
---|
1013 | end;
|
---|
1014 | end;
|
---|
1015 |
|
---|
1016 | begin
|
---|
1017 | list := TStringList.Create;
|
---|
1018 | list.Sorted := True;
|
---|
1019 | for i := 0 to High(Fdat_files) do
|
---|
1020 | begin
|
---|
1021 | if ((Length(ext) = 0) or (Pos(Fdat_files[i].Extension, ext) > 0)) and
|
---|
1022 | ((Length(pattern) = 0) or
|
---|
1023 | (Pos(UpperCase(pattern), UpperCase(Fdat_files[i].Name)) > 0)) then
|
---|
1024 | begin
|
---|
1025 | if (NoEmptyFiles = False) or ((Fdat_files[i].FileType and $02) = 0) then
|
---|
1026 | begin
|
---|
1027 | if AppSettings.FilenumbersAsHex then
|
---|
1028 | id := IntToHex(Fdat_files[i].ID, 4)
|
---|
1029 | else
|
---|
1030 | id := FormatNumber(Fdat_files[i].ID, 5, '0');
|
---|
1031 | name := Fdat_files[i].Name;
|
---|
1032 | extension := Fdat_files[i].Extension;
|
---|
1033 |
|
---|
1034 | case sort of
|
---|
1035 | stIDAsc, stIDDesc: list.Add(id + ';' + name + ';' + extension);
|
---|
1036 | stNameAsc, stNameDesc: list.Add(name + ';' + id + ';' + extension);
|
---|
1037 | stExtAsc, stExtDesc: list.Add(extension + ';' + id + ';' + name);
|
---|
1038 | end;
|
---|
1039 | end;
|
---|
1040 | end;
|
---|
1041 | end;
|
---|
1042 | SetLength(Result, list.Count);
|
---|
1043 | fields := TStringList.Create;
|
---|
1044 | if sort in [stIDAsc, stNameAsc, stExtAsc] then
|
---|
1045 | for i := 0 to list.Count - 1 do
|
---|
1046 | begin
|
---|
1047 | getfields;
|
---|
1048 | Result[i] := id + '-' + name + '.' + extension;
|
---|
1049 | end
|
---|
1050 | else
|
---|
1051 | for i := list.Count - 1 downto 0 do
|
---|
1052 | begin
|
---|
1053 | getfields;
|
---|
1054 | Result[list.Count - i - 1] := id + '-' + name + '.' + extension;
|
---|
1055 | end;
|
---|
1056 | list.Free;
|
---|
1057 | fields.Free;
|
---|
1058 | end;
|
---|
1059 |
|
---|
1060 |
|
---|
1061 |
|
---|
1062 |
|
---|
1063 | function TOniDataADB.GetFilesCount: LongWord;
|
---|
1064 | begin
|
---|
1065 | Result := Length(Fdat_files);
|
---|
1066 | end;
|
---|
1067 |
|
---|
1068 |
|
---|
1069 |
|
---|
1070 |
|
---|
1071 | function TOniDataADB.GetExtensionsList: TStringArray;
|
---|
1072 | var
|
---|
1073 | i: LongWord;
|
---|
1074 | begin
|
---|
1075 | SetLength(Result, Length(Fdat_extensionsmap));
|
---|
1076 | for i := 0 to High(Result) do
|
---|
1077 | begin
|
---|
1078 | with Fdat_extensionsmap[i] do
|
---|
1079 | begin
|
---|
1080 | Result[i] := Extension[3] + Extension[2] + Extension[1] + Extension[0] +
|
---|
1081 | ' (' + IntToStr(ExtCount) + ')';
|
---|
1082 | end;
|
---|
1083 | end;
|
---|
1084 | end;
|
---|
1085 |
|
---|
1086 |
|
---|
1087 |
|
---|
1088 |
|
---|
1089 | function TOniDataADB.GetExtendedExtensionsList: TExtensionsMap;
|
---|
1090 | var
|
---|
1091 | i, j: LongWord;
|
---|
1092 | temps: String;
|
---|
1093 | Data: Tdata;
|
---|
1094 | begin
|
---|
1095 | SetLength(Result, 0);
|
---|
1096 | FQuery.SQL.Text := 'SELECT ext,ident FROM extlist ORDER BY ext ASC;';
|
---|
1097 | FQuery.Open;
|
---|
1098 | if FQuery.RecordCount > 0 then
|
---|
1099 | begin
|
---|
1100 | SetLength(Result, FQuery.RecordCount);
|
---|
1101 | i := 0;
|
---|
1102 | repeat
|
---|
1103 | temps := FQuery.FieldByName('ext').AsString;
|
---|
1104 | for j := 0 to 3 do
|
---|
1105 | Result[i].Extension[j] := temps[4 - j];
|
---|
1106 | Data := DecodeHexString(FQuery.FieldByName('ident').AsString);
|
---|
1107 | for j := 0 to 7 do
|
---|
1108 | Result[i].Ident[j] := Data[j];
|
---|
1109 | Inc(i);
|
---|
1110 | FQuery.Next;
|
---|
1111 | until FQuery.EOF;
|
---|
1112 | end;
|
---|
1113 | FQuery.Close;
|
---|
1114 | end;
|
---|
1115 |
|
---|
1116 |
|
---|
1117 |
|
---|
1118 |
|
---|
1119 | function TOniDataADB.GetNamedFilesMap: TNamedFilesMap;
|
---|
1120 | var
|
---|
1121 | i: LongWord;
|
---|
1122 | temp: Integer;
|
---|
1123 | temps: String;
|
---|
1124 | temparray: array of record
|
---|
1125 | id: Integer;
|
---|
1126 | fullname: String[50];
|
---|
1127 | end;
|
---|
1128 | begin
|
---|
1129 | SetLength(temparray, 0);
|
---|
1130 | FQuery.SQL.Text :=
|
---|
1131 | 'SELECT id,(extension+name) AS xname FROM datfiles WHERE Length(name)>0 ORDER BY extension,name ASC;';
|
---|
1132 | FQuery.Open;
|
---|
1133 | if FQuery.RecordCount > 0 then
|
---|
1134 | begin
|
---|
1135 | repeat
|
---|
1136 | temp := FQuery.FieldByName('id').AsInteger;
|
---|
1137 | temps := FQuery.FieldByName('xname').AsString;
|
---|
1138 |
|
---|
1139 | SetLength(temparray, Length(temparray) + 1);
|
---|
1140 | if Length(temparray) > 1 then
|
---|
1141 | begin
|
---|
1142 | for i := High(temparray) - 1 downto 0 do
|
---|
1143 | begin
|
---|
1144 | if StringSmaller(temps, temparray[i].fullname) then
|
---|
1145 | begin
|
---|
1146 | temparray[i + 1] := temparray[i];
|
---|
1147 | if i = 0 then
|
---|
1148 | begin
|
---|
1149 | temparray[i].id := temp;
|
---|
1150 | temparray[i].fullname := temps;
|
---|
1151 | end;
|
---|
1152 | end
|
---|
1153 | else
|
---|
1154 | begin
|
---|
1155 | temparray[i + 1].id := temp;
|
---|
1156 | temparray[i + 1].fullname := temps;
|
---|
1157 | Break;
|
---|
1158 | end;
|
---|
1159 | end;
|
---|
1160 | end
|
---|
1161 | else
|
---|
1162 | begin
|
---|
1163 | temparray[0].id := temp;
|
---|
1164 | temparray[0].fullname := temps;
|
---|
1165 | end;
|
---|
1166 | FQuery.Next;
|
---|
1167 | until FQuery.EOF;
|
---|
1168 | end;
|
---|
1169 | FQuery.Close;
|
---|
1170 | SetLength(Result, Length(temparray));
|
---|
1171 | for i := 0 to High(temparray) do
|
---|
1172 | begin
|
---|
1173 | Result[i].FileNumber := temparray[i].id;
|
---|
1174 | Result[i].blubb := 0;
|
---|
1175 | end;
|
---|
1176 | end;
|
---|
1177 |
|
---|
1178 |
|
---|
1179 |
|
---|
1180 |
|
---|
1181 | function TOniDataADB.LoadDatFile(fileid: LongWord): Tdata;
|
---|
1182 | var
|
---|
1183 | mem: TStream;
|
---|
1184 | begin
|
---|
1185 | if fileid < Self.GetFilesCount then
|
---|
1186 | begin
|
---|
1187 | FQuery.SQL.Text := 'SELECT data FROM datfiles WHERE id=' + IntToStr(fileid) + ';';
|
---|
1188 | FQuery.Open;
|
---|
1189 | if FQuery.RecordCount > 0 then
|
---|
1190 | begin
|
---|
1191 | mem := FQuery.CreateBlobStream(FQuery.FieldByName('data'), bmRead);
|
---|
1192 | SetLength(Result, mem.Size);
|
---|
1193 | mem.Seek(0, soFromBeginning);
|
---|
1194 | mem.Read(Result[0], mem.Size);
|
---|
1195 | mem.Free;
|
---|
1196 | end;
|
---|
1197 | FQuery.Close;
|
---|
1198 | end;
|
---|
1199 | end;
|
---|
1200 |
|
---|
1201 |
|
---|
1202 |
|
---|
1203 |
|
---|
1204 | procedure TOniDataADB.UpdateDatFile(fileid: LongWord; Data: Tdata);
|
---|
1205 | var
|
---|
1206 | MimeCoder: TStringFormat_MIME64;
|
---|
1207 | mem: TMemoryStream;
|
---|
1208 | begin
|
---|
1209 | if fileid < Self.GetFilesCount then
|
---|
1210 | begin
|
---|
1211 | mimecoder := TStringFormat_MIME64.Create;
|
---|
1212 | mem := TMemoryStream.Create;
|
---|
1213 | mem.Write(Data[0], Length(Data));
|
---|
1214 | mem.Seek(0, soFromBeginning);
|
---|
1215 | FQuery.SQL.Text := 'UPDATE datfiles SET data=MimeToBin("' +
|
---|
1216 | MimeCoder.StrTo(mem.Memory, mem.Size) + '"), size=' + IntToStr(mem.Size) +
|
---|
1217 | ' WHERE id=' + IntToStr(fileid) + ';';
|
---|
1218 | FQuery.ExecSQL;
|
---|
1219 | mem.Free;
|
---|
1220 | mimecoder.Free;
|
---|
1221 | end;
|
---|
1222 | UpdateListCache;
|
---|
1223 | end;
|
---|
1224 |
|
---|
1225 |
|
---|
1226 |
|
---|
1227 |
|
---|
1228 | procedure TOniDataADB.LoadDatFilePart(fileid, offset, size: LongWord; target: Pointer);
|
---|
1229 | var
|
---|
1230 | mem: TStream;
|
---|
1231 | begin
|
---|
1232 | if fileid < Self.GetFilesCount then
|
---|
1233 | begin
|
---|
1234 | FQuery.SQL.Text := 'SELECT data FROM datfiles WHERE id=' + IntToStr(fileid) + ';';
|
---|
1235 | FQuery.Open;
|
---|
1236 | if FQuery.RecordCount > 0 then
|
---|
1237 | begin
|
---|
1238 | mem := FQuery.CreateBlobStream(FQuery.FieldByName('data'), bmRead);
|
---|
1239 | mem.Seek(offset, soFromBeginning);
|
---|
1240 | mem.Read(target^, size);
|
---|
1241 | mem.Free;
|
---|
1242 | end;
|
---|
1243 | FQuery.Close;
|
---|
1244 | end;
|
---|
1245 | end;
|
---|
1246 |
|
---|
1247 |
|
---|
1248 |
|
---|
1249 |
|
---|
1250 | procedure TOniDataADB.UpdateDatFilePart(fileid, offset, size: LongWord; target: Pointer);
|
---|
1251 | var
|
---|
1252 | MimeCoder: TStringFormat_MIME64;
|
---|
1253 | mem: TMemoryStream;
|
---|
1254 | Data: Tdata;
|
---|
1255 | begin
|
---|
1256 | if fileid < Self.GetFilesCount then
|
---|
1257 | begin
|
---|
1258 | Data := Self.LoadDatFile(fileid);
|
---|
1259 | mimecoder := TStringFormat_MIME64.Create;
|
---|
1260 | mem := TMemoryStream.Create;
|
---|
1261 | mem.Write(Data[0], Length(Data));
|
---|
1262 | mem.Seek(offset, soFromBeginning);
|
---|
1263 | mem.Write(target^, size);
|
---|
1264 | mem.Seek(0, soFromBeginning);
|
---|
1265 | FQuery.SQL.Text := 'UPDATE datfiles SET data=MimeToBin("' +
|
---|
1266 | MimeCoder.StrTo(mem.Memory, mem.Size) + '") WHERE id=' + IntToStr(fileid) + ';';
|
---|
1267 | FQuery.ExecSQL;
|
---|
1268 | mem.Free;
|
---|
1269 | mimecoder.Free;
|
---|
1270 | end;
|
---|
1271 | end;
|
---|
1272 |
|
---|
1273 |
|
---|
1274 |
|
---|
1275 |
|
---|
1276 | function TOniDataADB.GetRawList(fileid: LongWord): TRawList;
|
---|
1277 | var
|
---|
1278 | i: LongWord;
|
---|
1279 | begin
|
---|
1280 | SetLength(Result, 0);
|
---|
1281 | FQuery.SQL.Text := 'SELECT [src_link_offset],[size],[sep] FROM rawmap WHERE [src_id]=' +
|
---|
1282 | IntToStr(fileid) + ' ORDER BY src_link_offset ASC;';
|
---|
1283 | FQuery.Open;
|
---|
1284 | if FQuery.RecordCount > 0 then
|
---|
1285 | begin
|
---|
1286 | FQuery.First;
|
---|
1287 | SetLength(Result, FQuery.RecordCount);
|
---|
1288 | i := 0;
|
---|
1289 | repeat
|
---|
1290 | Result[i].src_id := fileid;
|
---|
1291 | Result[i].src_offset := FQuery.FieldByName('src_link_offset').AsInteger;
|
---|
1292 | Result[i].raw_addr := 0;
|
---|
1293 | Result[i].raw_size := FQuery.FieldByName('size').AsInteger;
|
---|
1294 | Result[i].loc_sep := FQuery.FieldByName('sep').AsBoolean;
|
---|
1295 | Inc(i);
|
---|
1296 | FQuery.Next;
|
---|
1297 | until FQuery.EOF;
|
---|
1298 | end;
|
---|
1299 | FQuery.Close;
|
---|
1300 | end;
|
---|
1301 |
|
---|
1302 |
|
---|
1303 |
|
---|
1304 |
|
---|
1305 | procedure TOniDataADB.LoadRawFile(fileid, dat_offset: LongWord; target: Pointer);
|
---|
1306 | var
|
---|
1307 | mem: TStream;
|
---|
1308 | begin
|
---|
1309 | if fileid < Self.GetFilesCount then
|
---|
1310 | begin
|
---|
1311 | FQuery.SQL.Text := 'SELECT data FROM rawmap WHERE (src_id=' +
|
---|
1312 | IntToStr(fileid) + ') AND (src_link_offset=' + IntToStr(dat_offset) + ');';
|
---|
1313 | FQuery.Open;
|
---|
1314 | if FQuery.RecordCount > 0 then
|
---|
1315 | begin
|
---|
1316 | mem := FQuery.CreateBlobStream(FQuery.FieldByName('data'), bmRead);
|
---|
1317 | mem.Seek(0, soFromBeginning);
|
---|
1318 | mem.Read(target^, mem.size);
|
---|
1319 | mem.Free;
|
---|
1320 | end;
|
---|
1321 | FQuery.Close;
|
---|
1322 | end;
|
---|
1323 | end;
|
---|
1324 |
|
---|
1325 |
|
---|
1326 |
|
---|
1327 |
|
---|
1328 | procedure TOniDataADB.UpdateRawFile(fileid, dat_offset: LongWord;
|
---|
1329 | size: LongWord; target: Pointer);
|
---|
1330 | var
|
---|
1331 | MimeCoder: TStringFormat_MIME64;
|
---|
1332 | mem: TMemoryStream;
|
---|
1333 | begin
|
---|
1334 | if fileid < Self.GetFilesCount then
|
---|
1335 | begin
|
---|
1336 | mimecoder := TStringFormat_MIME64.Create;
|
---|
1337 | mem := TMemoryStream.Create;
|
---|
1338 | mem.Write(target^, size);
|
---|
1339 | mem.Seek(0, soFromBeginning);
|
---|
1340 | FQuery.SQL.Text := 'UPDATE rawmap SET data=MimeToBin("' + MimeCoder.StrTo(
|
---|
1341 | mem.Memory, mem.Size) + '") WHERE (src_id=' + IntToStr(fileid) +
|
---|
1342 | ') AND (src_link_offset=' + IntToStr(dat_offset) + ');';
|
---|
1343 | FQuery.ExecSQL;
|
---|
1344 | mem.Free;
|
---|
1345 | mimecoder.Free;
|
---|
1346 | end;
|
---|
1347 | end;
|
---|
1348 |
|
---|
1349 |
|
---|
1350 |
|
---|
1351 |
|
---|
1352 | procedure TOniDataADB.LoadRawFilePart(fileid, dat_offset: LongWord;
|
---|
1353 | offset, size: LongWord; target: Pointer);
|
---|
1354 | var
|
---|
1355 | Data: Tdata;
|
---|
1356 | mem: TMemoryStream;
|
---|
1357 | begin
|
---|
1358 | if fileid < Self.GetFilesCount then
|
---|
1359 | begin
|
---|
1360 | SetLength(Data, Self.GetRawInfo(fileid, dat_offset).raw_size);
|
---|
1361 | Self.LoadRawFile(fileid, dat_offset, @Data[0]);
|
---|
1362 | mem := TMemoryStream.Create;
|
---|
1363 | mem.Write(Data[offset], size);
|
---|
1364 | mem.Read(target^, size);
|
---|
1365 | mem.Free;
|
---|
1366 | end;
|
---|
1367 | end;
|
---|
1368 |
|
---|
1369 |
|
---|
1370 |
|
---|
1371 |
|
---|
1372 | procedure TOniDataADB.UpdateRawFilePart(fileid, dat_offset: LongWord;
|
---|
1373 | offset, size: LongWord; target: Pointer);
|
---|
1374 | var
|
---|
1375 | MimeCoder: TStringFormat_MIME64;
|
---|
1376 | mem: TMemoryStream;
|
---|
1377 | Data: Tdata;
|
---|
1378 | begin
|
---|
1379 | if fileid < Self.GetFilesCount then
|
---|
1380 | begin
|
---|
1381 | SetLength(Data, Self.GetRawInfo(fileid, offset).raw_size);
|
---|
1382 | Self.LoadRawFile(fileid, offset, @Data[0]);
|
---|
1383 | mimecoder := TStringFormat_MIME64.Create;
|
---|
1384 | mem := TMemoryStream.Create;
|
---|
1385 | mem.Write(Data[0], Length(Data));
|
---|
1386 | mem.Seek(offset, soFromBeginning);
|
---|
1387 | mem.Write(target^, size);
|
---|
1388 | mem.Seek(0, soFromBeginning);
|
---|
1389 | FQuery.SQL.Text := 'UPDATE rawmap SET data=MimeToBin("' + MimeCoder.StrTo(
|
---|
1390 | mem.Memory, mem.Size) + '") WHERE (src_id=' + IntToStr(fileid) +
|
---|
1391 | ') AND (src_link_offset=' + IntToStr(dat_offset) + ');';
|
---|
1392 | FQuery.ExecSQL;
|
---|
1393 | mem.Free;
|
---|
1394 | mimecoder.Free;
|
---|
1395 | end;
|
---|
1396 | end;
|
---|
1397 |
|
---|
1398 |
|
---|
1399 |
|
---|
1400 |
|
---|
1401 |
|
---|
1402 |
|
---|
1403 |
|
---|
1404 |
|
---|
1405 |
|
---|
1406 |
|
---|
1407 |
|
---|
1408 | function CreateDataConnection(filename: String; backend: Integer): TOniData;
|
---|
1409 | var
|
---|
1410 | answer: Boolean;
|
---|
1411 | i: Integer;
|
---|
1412 | begin
|
---|
1413 | if Length(DataConnections) > 0 then
|
---|
1414 | begin
|
---|
1415 | for i := 0 to High(DataConnections) do
|
---|
1416 | begin
|
---|
1417 | if ExtractFileName(DataConnections[i].FFileName) = ExtractFileName(filename) then
|
---|
1418 | begin
|
---|
1419 | if DataConnections[i].FFileName <> filename then
|
---|
1420 | begin
|
---|
1421 | Result := nil;
|
---|
1422 | ShowMessage('You can not open two files with the same name at a time.');
|
---|
1423 | end
|
---|
1424 | else
|
---|
1425 | Result := DataConnections[i];
|
---|
1426 | Exit;
|
---|
1427 | end;
|
---|
1428 | end;
|
---|
1429 | end;
|
---|
1430 |
|
---|
1431 | if not FileExists(filename) then
|
---|
1432 | begin
|
---|
1433 | ShowMessage('File "' + filename + '" does not exist!');
|
---|
1434 | Result := nil;
|
---|
1435 | Exit;
|
---|
1436 | end;
|
---|
1437 |
|
---|
1438 | SetLength(DataConnections, Length(DataConnections) + 1);
|
---|
1439 | i := High(DataConnections);
|
---|
1440 | case backend of
|
---|
1441 | ODB_Dat:
|
---|
1442 | DataConnections[i] := TOniDataDat.Create(filename, answer);
|
---|
1443 | ODB_ADB:
|
---|
1444 | DataConnections[i] := TOniDataADB.Create(filename, answer);
|
---|
1445 | else
|
---|
1446 | ShowMessage('Unknown Backend');
|
---|
1447 | Result := nil;
|
---|
1448 | Exit;
|
---|
1449 | end;
|
---|
1450 |
|
---|
1451 | if answer then
|
---|
1452 | begin
|
---|
1453 | Result := DataConnections[i];
|
---|
1454 | // Result := True;
|
---|
1455 | end
|
---|
1456 | else
|
---|
1457 | begin
|
---|
1458 | ShowMessage('File not loaded');
|
---|
1459 | DataConnections[i].Close;
|
---|
1460 | DataConnections[i].Free;
|
---|
1461 | DataConnections[i] := nil;
|
---|
1462 | SetLength(DataConnections, Length(DataConnections) - 1);
|
---|
1463 | Result := nil;
|
---|
1464 | end;
|
---|
1465 | end;
|
---|
1466 |
|
---|
1467 |
|
---|
1468 |
|
---|
1469 |
|
---|
1470 | procedure CloseDataConnection(connection: TOniData);
|
---|
1471 | var
|
---|
1472 | i: Integer;
|
---|
1473 | found: Boolean;
|
---|
1474 | begin
|
---|
1475 | if Assigned(connection) then
|
---|
1476 | begin
|
---|
1477 | found := False;
|
---|
1478 | for i := 0 to High(DataConnections) do
|
---|
1479 | begin
|
---|
1480 | if not found then
|
---|
1481 | begin
|
---|
1482 | if DataConnections[i] = connection then
|
---|
1483 | begin
|
---|
1484 | DataConnections[i].Close;
|
---|
1485 | // DataConnections[i].Free;
|
---|
1486 | DataConnections[i] := nil;
|
---|
1487 | found := True;
|
---|
1488 | end;
|
---|
1489 | end
|
---|
1490 | else
|
---|
1491 | begin
|
---|
1492 | DataConnections[i - 1] := DataConnections[i];
|
---|
1493 | end;
|
---|
1494 | end;
|
---|
1495 | if found then
|
---|
1496 | SetLength(DataConnections, Length(DataConnections) - 1);
|
---|
1497 | end;
|
---|
1498 | end;
|
---|
1499 |
|
---|
1500 |
|
---|
1501 | function GetEmptyFileInfo: TFileInfo;
|
---|
1502 | begin
|
---|
1503 | Result.ID := -1;
|
---|
1504 | Result.FileName := '';
|
---|
1505 | Result.FileNameHex := '';
|
---|
1506 | Result.Extension := '';
|
---|
1507 | Result.Name := '';
|
---|
1508 | Result.Size := 0;
|
---|
1509 | Result.FileType := 0;
|
---|
1510 | Result.DatAddr := 0;
|
---|
1511 | Result.opened := False;
|
---|
1512 | end;
|
---|
1513 |
|
---|
1514 |
|
---|
1515 |
|
---|
1516 |
|
---|
1517 | constructor TOniDataEmpty.Create(OLDBFilename: String; var Result: Boolean);
|
---|
1518 | var
|
---|
1519 | i, j: Byte;
|
---|
1520 | temps: String;
|
---|
1521 | begin
|
---|
1522 | ShowMessage('OLD');
|
---|
1523 | end;
|
---|
1524 |
|
---|
1525 | procedure TOniDataEmpty.Close;
|
---|
1526 | begin
|
---|
1527 | ShowMessage('OLD');
|
---|
1528 | end;
|
---|
1529 |
|
---|
1530 | end.
|
---|