ex62.pp 653 B

12345678910111213141516171819202122232425262728
  1. Program Example62;
  2. { Program to demonstrate the ReadLink function. }
  3. Uses linux;
  4. Var F : Text;
  5. S : String;
  6. begin
  7. Assign (F,'test.txt');
  8. Rewrite (F);
  9. Writeln (F,'This is written to test.txt');
  10. Close(f);
  11. { new.txt and test.txt are now the same file }
  12. if not SymLink ('test.txt','new.txt') then
  13. writeln ('Error when symlinking !');
  14. S:=ReadLink('new.txt');
  15. If S='' then
  16. Writeln ('Error reading link !')
  17. Else
  18. Writeln ('Link points to : ',S);
  19. { Now remove links }
  20. If not Unlink ('new.txt') then
  21. Writeln ('Error when unlinking !');
  22. If not Unlink ('test.txt') then
  23. Writeln ('Error when unlinking !');
  24. end.