source: oup/current/FileClasses/_Extensions.pas@ 232

Last change on this file since 232 was 231, checked in by alloc, 17 years ago
File size: 1.6 KB
RevLine 
[228]1unit _Extensions;
2
3interface
4
[231]5uses
6 _FileTypes;
7
[228]8type
9 TExtension = class
10 private
11 FConnectionID: Integer;
[229]12 FExt: String;
[228]13 FFiles: array of Integer;
14 function GetFile(ID: Integer): Integer;
15 function GetFileCount: Integer;
16 public
17 constructor Create(ConnectionID: Integer; Ext: String); virtual;
18 procedure InitList;
[229]19 property Ext: String read FExt;
[228]20 property Files[ID: Integer]: Integer read GetFile;
21 property FileCount: Integer read GetFileCount;
22 end;
23
[229]24 TExtensions = array of TExtension;
25
[228]26
[229]27
[228]28implementation
29
30uses
31 Classes, StrUtils, SysUtils, ConnectionManager, TypeDefs;
32
33{ TExtension }
34
35constructor TExtension.Create(ConnectionID: Integer; Ext: String);
[229]36begin
37 FConnectionID := ConnectionID;
38 FExt := Ext;
39end;
40
41function TExtension.GetFile(ID: Integer): Integer;
42begin
43 Result := FFiles[ID];
44end;
45
46function TExtension.GetFileCount: Integer;
47begin
48 Result := Length(FFiles);
49end;
50
51procedure TExtension.InitList;
[228]52var
53 files: TStrings;
54 i: Integer;
55 fid: Integer;
56 finfo: TFileInfo;
57begin
58 files := TStringList.Create;
59 files := ConManager.Connection[FConnectionID].GetFilesList(Ext, '', False, ST_NameAsc);
60 if files.Count > 0 then
61 begin
62 for i := 0 to files.Count - 1 do
63 begin
64 fid := StrToInt(MidStr(files.Strings[i], 1, 5));
65 finfo := ConManager.Connection[FConnectionID].GetFileInfo(fid);
66 if Length(finfo.Name) > 0 then
67 begin
68 SetLength(FFiles, Length(FFiles) + 1);
69 FFiles[High(FFiles)] := fid;
70 end;
71 end;
72 end;
73 files.Free;
74end;
75
76end.
Note: See TracBrowser for help on using the repository browser.