[228] | 1 | unit _Extensions;
|
---|
| 2 |
|
---|
| 3 | interface
|
---|
| 4 |
|
---|
[231] | 5 | uses
|
---|
| 6 | _FileTypes;
|
---|
| 7 |
|
---|
[228] | 8 | type
|
---|
| 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] | 28 | implementation
|
---|
| 29 |
|
---|
| 30 | uses
|
---|
| 31 | Classes, StrUtils, SysUtils, ConnectionManager, TypeDefs;
|
---|
| 32 |
|
---|
| 33 | { TExtension }
|
---|
| 34 |
|
---|
| 35 | constructor TExtension.Create(ConnectionID: Integer; Ext: String);
|
---|
[229] | 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;
|
---|
[228] | 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.
|
---|