summaryrefslogtreecommitdiff
path: root/fpcdocs/olinuxex/ex62.pp
blob: b77e3ca7aebc9323bd7dfcc024c26b009a1348db (plain)
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
Program Example62;

{ Program to demonstrate the ReadLink function. }

Uses oldlinux;

Var F : Text;
    S : String;

begin
  Assign (F,'test.txt');
  Rewrite (F);
  Writeln (F,'This is written to test.txt');
  Close(f);
  { new.txt and test.txt are now the same file }
  if not SymLink ('test.txt','new.txt') then
    writeln ('Error when symlinking !');
  S:=ReadLink('new.txt');
  If S='' then
    Writeln ('Error reading link !')
  Else
    Writeln ('Link points to : ',S);
 { Now remove links }
 If not Unlink ('new.txt') then
   Writeln ('Error when unlinking !');
 If not Unlink ('test.txt') then
   Writeln ('Error when unlinking !');
end.