| 1 |
|
unit _MetaManager; |
| 2 |
|
interface |
| 3 |
|
|
| 4 |
< |
uses _FileTypes, TXAN, TXMP, _EmptyFile; |
| 5 |
< |
|
| 6 |
< |
type |
| 7 |
< |
TFileType = class of TFile; |
| 8 |
< |
TFileDesc = record |
| 9 |
< |
ext: String; |
| 10 |
< |
ftype: TFileType; |
| 11 |
< |
end; |
| 12 |
< |
|
| 13 |
< |
const |
| 14 |
< |
FileDescs: array[0..1] of TFileDesc = ( |
| 15 |
< |
(ext: 'TXAN'; ftype: TFile_TXAN), |
| 16 |
< |
(ext: 'TXMP'; ftype: TFile_TXMP) |
| 17 |
< |
); |
| 4 |
> |
uses _MetaTypes; |
| 5 |
|
|
| 6 |
|
type |
| 7 |
|
TMetaManager = class |
| 8 |
|
protected |
| 9 |
|
FFiles: array of TFile; |
| 10 |
+ |
FRoot: array of TExtension; |
| 11 |
|
FConnectionID: Integer; |
| 12 |
|
function GetFileCount: Integer; |
| 13 |
|
function GetFileById(Id: Integer): TFile; |
| 16 |
|
public |
| 17 |
|
constructor Create(ConnectionID: Integer); |
| 18 |
|
procedure InitFile(id: Integer); |
| 19 |
+ |
procedure InitFileFields(id: Integer); |
| 20 |
|
|
| 21 |
|
property FileCount: Integer read GetFileCount; |
| 22 |
|
property FileById[Id: Integer]: TFile read GetFileById; |
| 23 |
|
end; |
| 24 |
|
|
| 25 |
+ |
var |
| 26 |
+ |
Meta: TMetaManager; |
| 27 |
+ |
|
| 28 |
|
implementation |
| 29 |
|
|
| 30 |
|
uses |
| 31 |
< |
Classes, ConnectionManager, Access_OniArchive, TypeDefs, Dialogs, SysUtils, StrUtils; |
| 31 |
> |
Classes, ConnectionManager, Access_OniArchive, TypeDefs, |
| 32 |
> |
Dialogs, SysUtils, StrUtils; |
| 33 |
|
|
| 34 |
|
{ TFileManager } |
| 35 |
|
|
| 51 |
|
|
| 52 |
|
procedure TMetaManager.InitFile(id: Integer); |
| 53 |
|
var |
| 61 |
– |
// i: Integer; |
| 54 |
|
typei: Integer; |
| 55 |
|
finfo: TFileInfo; |
| 56 |
|
begin |
| 65 |
|
begin |
| 66 |
|
if FileDescs[typei].ext = finfo.Extension then |
| 67 |
|
begin |
| 68 |
< |
FFiles[id] := TFileType(FileDescs[typei].ftype).Create(FConnectionID, id); |
| 68 |
> |
FFiles[id] := TFileClass(FileDescs[typei].ftype).Create(FConnectionID, id); |
| 69 |
|
Break; |
| 70 |
|
end; |
| 71 |
|
end; |
| 78 |
|
end; |
| 79 |
|
end; |
| 80 |
|
|
| 81 |
+ |
procedure TMetaManager.InitFileFields(id: Integer); |
| 82 |
+ |
begin |
| 83 |
+ |
if id < ConManager.Connection[FConnectionID].GetFileCount then |
| 84 |
+ |
begin |
| 85 |
+ |
if not Assigned(FFiles[id]) then |
| 86 |
+ |
begin |
| 87 |
+ |
InitFile(id); |
| 88 |
+ |
if not (FFiles[id] is TFile_Empty) then |
| 89 |
+ |
FFiles[id].InitDataFields; |
| 90 |
+ |
end; |
| 91 |
+ |
end; |
| 92 |
+ |
end; |
| 93 |
+ |
|
| 94 |
|
procedure TMetaManager.InitRootFiles; |
| 95 |
|
var |
| 96 |
|
files: TStrings; |
| 120 |
|
begin |
| 121 |
|
if FileDescs[typei].ext = finfo.Extension then |
| 122 |
|
begin |
| 123 |
< |
FFiles[fid] := TFileType(FileDescs[typei].ftype).Create(FConnectionID, fid); |
| 123 |
> |
FFiles[fid] := TFileClass(FileDescs[typei].ftype).Create(FConnectionID, fid); |
| 124 |
|
Break; |
| 125 |
|
end; |
| 126 |
|
end; |