Changeset 229 for oup/current/FileClasses
- Timestamp:
- Jun 20, 2007, 12:57:51 PM (17 years ago)
- Location:
- oup/current/FileClasses
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
oup/current/FileClasses/_Extensions.pas
r228 r229 7 7 private 8 8 FConnectionID: Integer; 9 FExt: String; 9 10 FFiles: array of Integer; 10 11 function GetFile(ID: Integer): Integer; … … 13 14 constructor Create(ConnectionID: Integer; Ext: String); virtual; 14 15 procedure InitList; 16 property Ext: String read FExt; 15 17 property Files[ID: Integer]: Integer read GetFile; 16 18 property FileCount: Integer read GetFileCount; 17 19 end; 20 21 TExtensions = array of TExtension; 22 18 23 19 24 … … 26 31 27 32 constructor TExtension.Create(ConnectionID: Integer; Ext: String); 33 begin 34 FConnectionID := ConnectionID; 35 FExt := Ext; 36 end; 37 38 function TExtension.GetFile(ID: Integer): Integer; 39 begin 40 Result := FFiles[ID]; 41 end; 42 43 function TExtension.GetFileCount: Integer; 44 begin 45 Result := Length(FFiles); 46 end; 47 48 procedure TExtension.InitList; 28 49 var 29 50 files: TStrings; … … 50 71 end; 51 72 52 function TExtension.GetFile(ID: Integer): Integer;53 begin54 Result := FFiles[ID];55 end;56 57 function TExtension.GetFileCount: Integer;58 begin59 Result := Length(FFiles);60 end;61 62 procedure TExtension.InitList;63 begin64 Exit;65 end;66 67 73 end. -
oup/current/FileClasses/_MetaManager.pas
r228 r229 8 8 protected 9 9 FFiles: array of TFile; 10 FRoot: array of TExtension;10 FRoot: TExtensions; 11 11 FConnectionID: Integer; 12 FDataAccess: TObject; 12 13 function GetFileCount: Integer; 13 14 function GetFileById(Id: Integer): TFile; 15 function GetExt(Ext: String): TExtension; 16 procedure AddExt(Ext: String); 14 17 private 15 procedure Init RootFiles;18 procedure InitExts; 16 19 public 17 constructor Create(ConnectionID: Integer); 20 constructor Create(ConnectionID: Integer; DataAccess: TObject); 21 procedure InitExtFiles(Ext: String); 18 22 procedure InitFile(id: Integer); 19 23 procedure InitFileFields(id: Integer); 20 24 25 property Root: TExtensions read FRoot; 26 property RootExt[Ext: String]: TExtension read GetExt; 21 27 property FileCount: Integer read GetFileCount; 22 28 property FileById[Id: Integer]: TFile read GetFileById; 23 29 end; 24 30 25 var26 Meta: TMetaManager;27 28 31 implementation 29 32 30 33 uses 31 34 Classes, ConnectionManager, Access_OniArchive, TypeDefs, 32 Dialogs, SysUtils, StrUtils ;35 Dialogs, SysUtils, StrUtils, DataAccess; 33 36 34 37 { TFileManager } 35 38 36 constructor TMetaManager.Create(ConnectionID: Integer );39 constructor TMetaManager.Create(ConnectionID: Integer; DataAccess: TObject); 37 40 begin 38 41 FConnectionID := ConnectionID; 39 InitRootFiles; 42 FDataAccess := DataAccess; 43 SetLength(FFiles, TDataAccess(DataAccess).GetFileCount); 44 InitExts; 45 end; 46 47 function TMetaManager.GetExt(Ext: String): TExtension; 48 var 49 i: Integer; 50 begin 51 Result := nil; 52 if Length(FRoot) > 0 then 53 for i := 0 to High(FRoot) do 54 if FRoot[i].Ext = Ext then 55 begin 56 Result := FRoot[i]; 57 Break; 58 end; 59 end; 60 61 procedure TMetaManager.AddExt(Ext: String); 62 var 63 i: Integer; 64 begin 65 SetLength(FRoot, Length(FRoot) + 1); 66 for i := High(FRoot) downto 1 do 67 begin 68 if FRoot[i-1].Ext < Ext then 69 begin 70 FRoot[i] := TExtension.Create(FConnectionID, Ext); 71 Break; 72 end 73 else 74 FRoot[i] := FRoot[i-1]; 75 end; 76 if i = 0 then 77 FRoot[0] := TExtension.Create(FConnectionID, Ext); 40 78 end; 41 79 … … 92 130 end; 93 131 94 procedure TMetaManager.Init RootFiles;132 procedure TMetaManager.InitExtFiles(Ext: String); 95 133 var 96 134 files: TStrings; … … 136 174 end; 137 175 176 procedure TMetaManager.InitExts; 177 var 178 files: TStrings; 179 i: Integer; 180 fid: Integer; 181 finfo: TFileInfo; 182 begin 183 files := TStringList.Create; 184 files := TDataAccess(FDataAccess).GetFilesList('', '', False, ST_IDAsc); 185 SetLength(FRoot, 0); 186 if files.Count > 0 then 187 begin 188 for i := 0 to files.Count - 1 do 189 begin 190 fid := StrToInt(MidStr(files.Strings[i], 1, 5)); 191 finfo := TDataAccess(FDataAccess).GetFileInfo(fid); 192 if Length(finfo.Name) > 0 then 193 if not Assigned(GetExt(finfo.Extension)) then 194 AddExt(finfo.Extension); 195 end; 196 end; 197 files.Free; 198 end; 199 138 200 end. -
oup/current/FileClasses/_MetaTypes.pas
r228 r229 19 19 TFile_Empty = _EmptyFile.TFile_Empty; 20 20 TExtension = _Extensions.TExtension; 21 TExtensions = _Extensions.TExtensions; 21 22 22 23 TFileClass = class of TFile;
Note:
See TracChangeset
for help on using the changeset viewer.