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

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