| 1 |
unit _FileTypes; |
| 2 |
|
| 3 |
interface |
| 4 |
|
| 5 |
uses |
| 6 |
TypeDefs, _DataTypes; |
| 7 |
|
| 8 |
|
| 9 |
type |
| 10 |
TFile = class |
| 11 |
private |
| 12 |
FConnectionID: Integer; |
| 13 |
FFileID: Integer; |
| 14 |
|
| 15 |
FDatLinks: TDatLinkList; |
| 16 |
FDataFields: TDataFields; |
| 17 |
FRawParts: TRawDataList; |
| 18 |
|
| 19 |
function GetDatLinkByOffset(Offset: Integer): TDatLink; |
| 20 |
function GetDatLinkByIndex(ID: Integer): TDatLink; |
| 21 |
function GetFieldByOffset(Offset: Integer): TDataField; |
| 22 |
function GetFieldByIndex(ID: Integer): TDataField; |
| 23 |
function GetRawPartByOffset(Offset: Integer): TRawDataInfo; |
| 24 |
function GetRawPartByIndex(ID: Integer): TRawDataInfo; |
| 25 |
public |
| 26 |
constructor Create(ConnectionID, FileID: Integer); |
| 27 |
|
| 28 |
property LinkByOffset[Offset: Integer]: TDatLink read GetDatLinkByOffset; |
| 29 |
property LinkByIndex[ID: Integer]: TDatLink read GetDatLinkByIndex; |
| 30 |
|
| 31 |
property FieldByOffset[Offset: Integer]: TDataField read GetFieldByOffset; |
| 32 |
property FieldByIndex[ID: Integer]: TDataField read GetFieldByIndex; |
| 33 |
|
| 34 |
property RawPartByOffset[Offset: Integer]: TRawDataInfo read GetRawPartByOffset; |
| 35 |
property RawPartByIndex[ID: Integer]: TRawDataInfo read GetRawPartByIndex; |
| 36 |
end; |
| 37 |
|
| 38 |
|
| 39 |
implementation |
| 40 |
|
| 41 |
uses |
| 42 |
DatLinks, RawList; |
| 43 |
|
| 44 |
{ TFileType } |
| 45 |
|
| 46 |
constructor TFile.Create(ConnectionID, FileID: Integer); |
| 47 |
begin |
| 48 |
FConnectionID := ConnectionID; |
| 49 |
FFileID := FileID; |
| 50 |
|
| 51 |
FDatLinks := DatLinksManager.GetDatLinks(ConnectionID, FileID); |
| 52 |
FRawParts := RawLists.GetRawList(ConnectionID, FileID); |
| 53 |
end; |
| 54 |
|
| 55 |
|
| 56 |
function TFile.GetDatLinkByIndex(ID: Integer): TDatLink; |
| 57 |
begin |
| 58 |
if ID < Length(FDatLinks) then |
| 59 |
Result := FDatLinks[ID] |
| 60 |
else |
| 61 |
with Result do |
| 62 |
begin |
| 63 |
SrcOffset := -1; |
| 64 |
DestID := -1; |
| 65 |
PosDestExts := ''; |
| 66 |
end; |
| 67 |
end; |
| 68 |
|
| 69 |
function TFile.GetDatLinkByOffset(Offset: Integer): TDatLink; |
| 70 |
var |
| 71 |
i: Integer; |
| 72 |
begin |
| 73 |
Result.SrcOffset := -1; |
| 74 |
Result.DestID := -1; |
| 75 |
Result.PosDestExts := ''; |
| 76 |
|
| 77 |
if Length(FDatLinks) > 0 then |
| 78 |
begin |
| 79 |
for i := 0 to High(FDatLinks) do |
| 80 |
if FDatLinks[i].SrcOffset = Offset then |
| 81 |
break; |
| 82 |
if i < Length(FDatLinks) then |
| 83 |
Result := FDatLinks[i]; |
| 84 |
end; |
| 85 |
end; |
| 86 |
|
| 87 |
|
| 88 |
function TFile.GetFieldByIndex(ID: Integer): TDataField; |
| 89 |
begin |
| 90 |
if ID < Length(FDataFields) then |
| 91 |
Result := FDataFields[ID] |
| 92 |
else |
| 93 |
Result := nil; |
| 94 |
end; |
| 95 |
|
| 96 |
function TFile.GetFieldByOffset(Offset: Integer): TDataField; |
| 97 |
var |
| 98 |
i: Integer; |
| 99 |
begin |
| 100 |
Result := nil; |
| 101 |
|
| 102 |
if Length(FDataFields) > 0 then |
| 103 |
begin |
| 104 |
for i := 0 to High(FDataFields) do |
| 105 |
if FDataFields[i].Offset = Offset then |
| 106 |
break; |
| 107 |
if i < Length(FDataFields) then |
| 108 |
Result := FDataFields[i]; |
| 109 |
end; |
| 110 |
end; |
| 111 |
|
| 112 |
|
| 113 |
function TFile.GetRawPartByIndex(ID: Integer): TRawDataInfo; |
| 114 |
begin |
| 115 |
if ID < Length(FRawParts) then |
| 116 |
Result := FRawParts[ID] |
| 117 |
else |
| 118 |
with Result do |
| 119 |
begin |
| 120 |
SrcID := -1; |
| 121 |
SrcOffset := -1; |
| 122 |
RawAddr := -1; |
| 123 |
RawSize := -1; |
| 124 |
end; |
| 125 |
end; |
| 126 |
|
| 127 |
function TFile.GetRawPartByOffset(Offset: Integer): TRawDataInfo; |
| 128 |
var |
| 129 |
i: Integer; |
| 130 |
begin |
| 131 |
with Result do |
| 132 |
begin |
| 133 |
SrcID := -1; |
| 134 |
SrcOffset := -1; |
| 135 |
RawAddr := -1; |
| 136 |
RawSize := -1; |
| 137 |
end; |
| 138 |
|
| 139 |
if Length(FRawParts) > 0 then |
| 140 |
begin |
| 141 |
for i := 0 to High(FRawParts) do |
| 142 |
if FRawParts[i].SrcOffset = Offset then |
| 143 |
break; |
| 144 |
if i < Length(FRawParts) then |
| 145 |
Result := FRawParts[i]; |
| 146 |
end; |
| 147 |
end; |
| 148 |
|
| 149 |
end. |