[Overview][Constants][Types][Procedures and functions] | Reference for unit 'BaseUnix' (#rtl) |
Change owner of file
Source position: line 0
function FpChown( |
path: pChar; |
owner: TUid; |
group: TGid |
):cint; |
path: AnsiString; |
owner: TUid; |
group: TGid |
):cint; |
fpChown sets the User ID and Group ID of the file in Path to Owner,Group.
The function returns zero if the call was succesfull, a nonzero return value indicates an error.
The following error codes are returned:
|
Change file permission bits |
|
|
Check file access |
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.
No notes exist for this page yet.