-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestit.pas
48 lines (32 loc) · 994 Bytes
/
testit.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
program UTextFileTest;
uses
SysUtils,
UTextFile;
var
tf: CTextFile;
tfr: CTextFile;
path: AnsiString;
begin
path := '/tmp/utextfile/test.log';
tf := CTextFile.CreateTheFile(path);
tf.OpenFileForWrite();
Writeln('The status of ' + tf.GetPath + ' is ' + BoolToStr(tf.GetStatus, 'OPEN', 'CLOSED'));
tf.WriteToFile('test text');
tf.WriteToFile('test text2');
tf.WriteToFile('testline');
tf.CloseTheFile();
tfr := CTextFile.CreateTheFile(path);
tfr.OpenFileForRead();
Writeln('The status of ' + tfr.GetPath + ' is ' + BoolToStr(tfr.GetStatus, 'OPEN', 'CLOSED'));
repeat
WriteLn(IntToStr(tfr.GetLineNumber()) + ': ' + tfr.ReadFromFile());
until tfr.GetEof();
//WriteLn('Size of ', tfr.GetPath, ' is ', tfr.GetFileSize());
tfr.CloseTheFile();
path := '/tmp/firstname.log';
tf := CTextFile.CreateTheFile(path);
tf.OpenFileForWrite();
tf.WriteToFile('firstname line');
tf.CloseTheFile();
tf.RenameTheFile('newname.log');
end.