ex21.pp 704 B

12345678910111213141516171819202122232425262728293031
  1. Program Example21;
  2. { Program to demonstrate the Link and UnLink functions. }
  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 Link ('test.txt','new.txt') then
  13. writeln ('Error when linking !');
  14. { Removing test.txt still leaves new.txt }
  15. If not Unlink ('test.txt') then
  16. Writeln ('Error when unlinking !');
  17. Assign (f,'new.txt');
  18. Reset (F);
  19. While not EOF(f) do
  20. begin
  21. Readln(F,S);
  22. Writeln ('> ',s);
  23. end;
  24. Close (f);
  25. { Remove new.txt also }
  26. If not Unlink ('new.txt') then
  27. Writeln ('Error when unlinking !');
  28. end.