summaryrefslogtreecommitdiff
path: root/fpcdocs/bunixex/ex24.pp
blob: 579c72bb94d490ed9b5b91f71eb854b998b7d212 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
Program Example24;

{ Program to demonstrate the Chown function. }

Uses BaseUnix;

Var UID : TUid;
    GID : TGid;
    F : Text;

begin

  Writeln ('This will only work if you are root.');
  Write ('Enter a UID : ');readln(UID);
  Write ('Enter a GID : ');readln(GID);
  Assign (f,'test.txt');
  Rewrite (f);
  Writeln (f,'The owner of this file should become : ');
  Writeln (f,'UID : ',UID);
  Writeln (f,'GID : ',GID);
  Close (F);
  if fpChown ('test.txt',UID,GID)<>0 then
    if fpgeterrno=ESysEPERM then
      Writeln ('You are not root !')
    else
      Writeln ('Chmod failed with exit code : ',fpgeterrno)
  else
    Writeln ('Changed owner successfully !');
end.