| 1 | {$IFDEF INTERFACE}
|
|---|
| 2 |
|
|---|
| 3 | {$DEFINE TGListIndex := TGFileListIndex}
|
|---|
| 4 | {$DEFINE TGListItem := TGFileListItem}
|
|---|
| 5 | {$DEFINE TGList := TGFileListList}
|
|---|
| 6 | {$DEFINE INTERFACE}
|
|---|
| 7 | {$I 'GenericList.inc'}
|
|---|
| 8 |
|
|---|
| 9 | // TGFileList<TGFileListIndex, TGFileListItem>
|
|---|
| 10 | TGFileList = class(TGList)
|
|---|
| 11 | private
|
|---|
| 12 | FFileName: string;
|
|---|
| 13 | FMode: Word;
|
|---|
| 14 | FHandle: THandle;
|
|---|
| 15 | procedure SetFileName(const Value: string);
|
|---|
| 16 | procedure SetMode(const Value: Word);
|
|---|
| 17 | function GetOpenned: Boolean;
|
|---|
| 18 | public
|
|---|
| 19 | constructor Create; override;
|
|---|
| 20 | destructor Destroy; override;
|
|---|
| 21 | procedure Open;
|
|---|
| 22 | procedure Close;
|
|---|
| 23 | property FileName: string read FFileName write SetFileName;
|
|---|
| 24 | property Mode: Word read FMode write SetMode;
|
|---|
| 25 | property Openned: Boolean read GetOpenned;
|
|---|
| 26 | end;
|
|---|
| 27 |
|
|---|
| 28 | {$UNDEF INTERFACE}
|
|---|
| 29 | {$ENDIF}
|
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 | {$IFDEF IMPLEMENTATION}
|
|---|
| 33 |
|
|---|
| 34 | {$DEFINE TGListIndex := TGFileListIndex}
|
|---|
| 35 | {$DEFINE TGListItem := TGFileListItem}
|
|---|
| 36 | {$DEFINE TGList := TGFileListList}
|
|---|
| 37 | {$DEFINE IMPLEMENTATION}
|
|---|
| 38 | {$I 'GenericList.inc'}
|
|---|
| 39 |
|
|---|
| 40 | constructor TGFileList.Create;
|
|---|
| 41 | begin
|
|---|
| 42 | inherited;
|
|---|
| 43 | FHandle := feInvalidHandle;
|
|---|
| 44 | end;
|
|---|
| 45 |
|
|---|
| 46 | destructor TGFileList.Destroy;
|
|---|
| 47 | begin
|
|---|
| 48 | Close;
|
|---|
| 49 | inherited;
|
|---|
| 50 | end;
|
|---|
| 51 |
|
|---|
| 52 | procedure TGFileList.Open;
|
|---|
| 53 | begin
|
|---|
| 54 | If (Mode and fmCreate) > 0 then
|
|---|
| 55 | FHandle := FileCreate(FFileName, FMode, 438)
|
|---|
| 56 | else
|
|---|
| 57 | FHandle := FileOpen(FFileName, FMode);
|
|---|
| 58 | end;
|
|---|
| 59 |
|
|---|
| 60 | procedure TGFileList.Close;
|
|---|
| 61 | begin
|
|---|
| 62 | if FHandle <> feInvalidHandle then FileClose(FHandle);
|
|---|
| 63 | end;
|
|---|
| 64 |
|
|---|
| 65 | procedure TGFileList.SetFileName(const Value: string);
|
|---|
| 66 | begin
|
|---|
| 67 | if FFileName = Value then Exit;
|
|---|
| 68 | FFileName := Value;
|
|---|
| 69 | if FHandle <> feInvalidHandle then begin
|
|---|
| 70 | Close;
|
|---|
| 71 | Open;
|
|---|
| 72 | end;
|
|---|
| 73 | end;
|
|---|
| 74 |
|
|---|
| 75 | procedure TGFileList.SetMode(const Value: Word);
|
|---|
| 76 | begin
|
|---|
| 77 | if FMode = Value then Exit;
|
|---|
| 78 | FMode := Value;
|
|---|
| 79 | if FHandle <> feInvalidHandle then begin
|
|---|
| 80 | Close;
|
|---|
| 81 | Open;
|
|---|
| 82 | end;
|
|---|
| 83 | end;
|
|---|
| 84 |
|
|---|
| 85 | function TGFileList.GetOpenned: Boolean;
|
|---|
| 86 | begin
|
|---|
| 87 | Result := FHandle <> feInvalidHandle;
|
|---|
| 88 | end;
|
|---|
| 89 |
|
|---|
| 90 | {$UNDEF IMPLEMENTATION}
|
|---|
| 91 | {$ENDIF}
|
|---|
| 92 |
|
|---|