ex24.pp 668 B

12345678910111213141516171819202122232425262728
  1. Program Example24;
  2. { Program to demonstrate the Chown function. }
  3. Uses linux;
  4. Var UID,GID : Longint;
  5. F : Text;
  6. begin
  7. Writeln ('This will only work if you are root.');
  8. Write ('Enter a UID : ');readln(UID);
  9. Write ('Enter a GID : ');readln(GID);
  10. Assign (f,'test.txt');
  11. Rewrite (f);
  12. Writeln (f,'The owner of this file should become : ');
  13. Writeln (f,'UID : ',UID);
  14. Writeln (f,'GID : ',GID);
  15. Close (F);
  16. if not Chown ('test.txt',UID,GID) then
  17. if LinuxError=Sys_EPERM then
  18. Writeln ('You are not root !')
  19. else
  20. Writeln ('Chmod failed with exit code : ',LinuxError)
  21. else
  22. Writeln ('Changed owner successfully !');
  23. end.