source: branches/AS8051toC/Packages/TemplateGenerics/Generic/GenericFileList.inc

Last change on this file was 26, checked in by chronos, 12 years ago
  • Upraveno: Překlad rozdělen do fáze zpracování maker a druhé fáze zpracování instrukcí.
File size: 1.8 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 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
38constructor TGFileList.Create;
39begin
40 inherited;
41 FHandle := feInvalidHandle;
42end;
43
44destructor TGFileList.Destroy;
45begin
46 Close;
47 inherited;
48end;
49
50procedure TGFileList.Open;
51begin
52 If (Mode and fmCreate) > 0 then
53 FHandle := FileCreate(FFileName, FMode, 438)
54 else
55 FHandle := FileOpen(FFileName, FMode);
56end;
57
58procedure TGFileList.Close;
59begin
60 if FHandle <> feInvalidHandle then FileClose(FHandle);
61end;
62
63procedure TGFileList.SetFileName(const Value: string);
64begin
65 if FFileName = Value then Exit;
66 FFileName := Value;
67 if FHandle <> feInvalidHandle then begin
68 Close;
69 Open;
70 end;
71end;
72
73procedure TGFileList.SetMode(const Value: Word);
74begin
75 if FMode = Value then Exit;
76 FMode := Value;
77 if FHandle <> feInvalidHandle then begin
78 Close;
79 Open;
80 end;
81end;
82
83
84{$UNDEF IMPLEMENTATION}
85{$ENDIF}
86
Note: See TracBrowser for help on using the repository browser.