source: oup/current/FileClasses/_FileTypes.pas@ 203

Last change on this file since 203 was 126, checked in by alloc, 18 years ago
File size: 3.3 KB
Line 
1unit _FileTypes;
2
3interface
4
5uses
6 TypeDefs, _DataTypes;
7
8
9type
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
39implementation
40
41uses
42 DatLinks, RawList;
43
44{ TFileType }
45
46constructor TFile.Create(ConnectionID, FileID: Integer);
47begin
48 FConnectionID := ConnectionID;
49 FFileID := FileID;
50
51 FDatLinks := DatLinksManager.GetDatLinks(ConnectionID, FileID);
52 FRawParts := RawLists.GetRawList(ConnectionID, FileID);
53end;
54
55
56function TFile.GetDatLinkByIndex(ID: Integer): TDatLink;
57begin
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;
67end;
68
69function TFile.GetDatLinkByOffset(Offset: Integer): TDatLink;
70var
71 i: Integer;
72begin
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;
85end;
86
87
88function TFile.GetFieldByIndex(ID: Integer): TDataField;
89begin
90 if ID < Length(FDataFields) then
91 Result := FDataFields[ID]
92 else
93 Result := nil;
94end;
95
96function TFile.GetFieldByOffset(Offset: Integer): TDataField;
97var
98 i: Integer;
99begin
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;
110end;
111
112
113function TFile.GetRawPartByIndex(ID: Integer): TRawDataInfo;
114begin
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;
125end;
126
127function TFile.GetRawPartByOffset(Offset: Integer): TRawDataInfo;
128var
129 i: Integer;
130begin
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;
147end;
148
149end.
Note: See TracBrowser for help on using the repository browser.