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