ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/oup/current/FileClasses/_Extensions.pas
Revision: 231
Committed: Wed Jun 20 22:24:04 2007 UTC (18 years, 3 months ago) by alloc
Content type: text/x-pascal
File size: 1673 byte(s)
Log Message:

File Contents

# Content
1 unit _Extensions;
2
3 interface
4
5 uses
6 _FileTypes;
7
8 type
9 TExtension = class
10 private
11 FConnectionID: Integer;
12 FExt: String;
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;
19 property Ext: String read FExt;
20 property Files[ID: Integer]: Integer read GetFile;
21 property FileCount: Integer read GetFileCount;
22 end;
23
24 TExtensions = array of TExtension;
25
26
27
28 implementation
29
30 uses
31 Classes, StrUtils, SysUtils, ConnectionManager, TypeDefs;
32
33 { TExtension }
34
35 constructor TExtension.Create(ConnectionID: Integer; Ext: String);
36 begin
37 FConnectionID := ConnectionID;
38 FExt := Ext;
39 end;
40
41 function TExtension.GetFile(ID: Integer): Integer;
42 begin
43 Result := FFiles[ID];
44 end;
45
46 function TExtension.GetFileCount: Integer;
47 begin
48 Result := Length(FFiles);
49 end;
50
51 procedure TExtension.InitList;
52 var
53 files: TStrings;
54 i: Integer;
55 fid: Integer;
56 finfo: TFileInfo;
57 begin
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;
74 end;
75
76 end.