source: trunk/Packages/TemplateGenerics/Generic/GenericFileList.inc

Last change on this file was 1, checked in by chronos, 8 years ago
  • Imported initial version.
File size: 1.9 KB
Line 
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
40constructor TGFileList.Create;
41begin
42 inherited;
43 FHandle := feInvalidHandle;
44end;
45
46destructor TGFileList.Destroy;
47begin
48 Close;
49 inherited;
50end;
51
52procedure TGFileList.Open;
53begin
54 If (Mode and fmCreate) > 0 then
55 FHandle := FileCreate(FFileName, FMode, 438)
56 else
57 FHandle := FileOpen(FFileName, FMode);
58end;
59
60procedure TGFileList.Close;
61begin
62 if FHandle <> feInvalidHandle then FileClose(FHandle);
63end;
64
65procedure TGFileList.SetFileName(const Value: string);
66begin
67 if FFileName = Value then Exit;
68 FFileName := Value;
69 if FHandle <> feInvalidHandle then begin
70 Close;
71 Open;
72 end;
73end;
74
75procedure TGFileList.SetMode(const Value: Word);
76begin
77 if FMode = Value then Exit;
78 FMode := Value;
79 if FHandle <> feInvalidHandle then begin
80 Close;
81 Open;
82 end;
83end;
84
85function TGFileList.GetOpenned: Boolean;
86begin
87 Result := FHandle <> feInvalidHandle;
88end;
89
90{$UNDEF IMPLEMENTATION}
91{$ENDIF}
92
Note: See TracBrowser for help on using the repository browser.