Changeset 212 for oup/current/FileClasses/_FileTypes.pas
- Timestamp:
- Jun 12, 2007, 6:42:53 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
oup/current/FileClasses/_FileTypes.pas
r210 r212 17 17 FFileStream: TMemoryStream; 18 18 19 FCached: Boolean; 20 FChanged: Boolean; 21 19 22 FDatLinks: TDatLinkList; 20 23 FDataFields: TBlock; … … 31 34 function GetRawPartByOffset(Offset: Integer): TRawDataInfo; 32 35 function GetRawPartByIndex(ID: Integer): TRawDataInfo; 36 function GetChildCount: Integer; 33 37 public 34 38 constructor Create(ConnectionID, FileID: Integer); virtual; … … 42 46 property ConnectionID: Integer read FConnectionID; 43 47 48 property Cached: Boolean read FCached; 49 property Changed: Boolean read FChanged write FChanged; 50 51 property ChildCount: Integer read GetChildCount; 44 52 property LinkByOffset[Offset: Integer]: TDatLink read GetDatLinkByOffset; 45 53 property LinkByIndex[ID: Integer]: TDatLink read GetDatLinkByIndex; … … 63 71 64 72 uses 65 DatLinks, RawList, ConnectionManager, Dialogs ;73 DatLinks, RawList, ConnectionManager, Dialogs, _EmptyFile; 66 74 67 75 { TFileType } … … 79 87 FFileSize := fileinfo.Size; 80 88 81 FFileStream := TMemoryStream.Create; 82 ConManager.Connection[ConnectionID].LoadDatFile(FileID, TStream(FFileStream)); 89 FCached := False; 90 FChanged := False; 91 92 if not (Self is TFile_Empty) then 93 begin 94 FFileStream := TMemoryStream.Create; 95 ConManager.Connection[ConnectionID].LoadDatFile(FileID, TStream(FFileStream)); 96 end; 83 97 84 98 InitDatLinks(); … … 86 100 InitRawList(); 87 101 88 FFileStream.Free; 102 if not (Self is TFile_Empty) then 103 FFileStream.Free; 89 104 FFileStream := nil; 90 105 end; … … 97 112 98 113 function TFile.GetDatLinkByIndex(ID: Integer): TDatLink; 99 begin 100 if ID < Length(FDatLinks) then 101 Result := FDatLinks[ID] 114 var 115 i: Integer; 116 valids: Integer; 117 begin 118 if ID < GetChildCount then 119 begin 120 valids := 0; 121 i := 0; 122 repeat 123 if FDatLinks[i].DestID >= 0 then 124 begin 125 Inc(valids); 126 end; 127 Inc(i); 128 until valids > ID; 129 Result := FDatLinks[i - 1]; 130 end 102 131 else 103 132 with Result do … … 140 169 end; 141 170 171 172 function TFile.GetChildCount: Integer; 173 var 174 i: Integer; 175 begin 176 Result := Length(FDatLinks); 177 if Result > 0 then 178 begin 179 Result := 0; 180 for i := 0 to High(FDatLinks) do 181 if FDatLinks[i].DestID >= 0 then 182 Inc(Result); 183 end; 184 end; 142 185 143 186 function TFile.GetRawPartByIndex(ID: Integer): TRawDataInfo;
Note:
See TracChangeset
for help on using the changeset viewer.