ex22.pp 832 B

123456789101112131415161718192021222324252627282930313233
  1. Program Example22;
  2. { Program to demonstrate the SymLink 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 SymLink ('test.txt','new.txt') then
  13. writeln ('Error when symlinking !');
  14. { Removing test.txt still leaves new.txt
  15. Pointing now to a non-existent file ! }
  16. If not Unlink ('test.txt') then
  17. Writeln ('Error when unlinking !');
  18. Assign (f,'new.txt');
  19. { This should fail, since the symbolic link
  20. points to a non-existent file! }
  21. {$i-}
  22. Reset (F);
  23. {$i+}
  24. If IOResult=0 then
  25. Writeln ('This shouldn''t happen');
  26. { Now remove new.txt also }
  27. If not Unlink ('new.txt') then
  28. Writeln ('Error when unlinking !');
  29. end.