[228] | 1 | unit _Extensions;
|
---|
| 2 |
|
---|
| 3 | interface
|
---|
| 4 |
|
---|
| 5 | type
|
---|
| 6 | TExtension = class
|
---|
| 7 | private
|
---|
| 8 | FConnectionID: Integer;
|
---|
[229] | 9 | FExt: String;
|
---|
[228] | 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;
|
---|
[229] | 16 | property Ext: String read FExt;
|
---|
[228] | 17 | property Files[ID: Integer]: Integer read GetFile;
|
---|
| 18 | property FileCount: Integer read GetFileCount;
|
---|
| 19 | end;
|
---|
| 20 |
|
---|
[229] | 21 | TExtensions = array of TExtension;
|
---|
| 22 |
|
---|
[228] | 23 |
|
---|
[229] | 24 |
|
---|
[228] | 25 | implementation
|
---|
| 26 |
|
---|
| 27 | uses
|
---|
| 28 | Classes, StrUtils, SysUtils, ConnectionManager, TypeDefs;
|
---|
| 29 |
|
---|
| 30 | { TExtension }
|
---|
| 31 |
|
---|
| 32 | constructor TExtension.Create(ConnectionID: Integer; Ext: String);
|
---|
[229] | 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;
|
---|
[228] | 49 | var
|
---|
| 50 | files: TStrings;
|
---|
| 51 | i: Integer;
|
---|
| 52 | fid: Integer;
|
---|
| 53 | finfo: TFileInfo;
|
---|
| 54 | begin
|
---|
| 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;
|
---|
| 71 | end;
|
---|
| 72 |
|
---|
| 73 | end.
|
---|