ex24.pp 681 B

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