UNIX Free Pascal



              

. - 2


Halt(1);

end;

val(Paramstr(3),GID,Code);

if Code<>0 then

begin

Writeln('Error!!!');

Writeln('Format: ./task <Filename> <UID> <GID>');

Halt(1);

end;

if not Chown(ParamStr(1),UID,GID) then

if LinuxError=Sys_EPERM then

Writeln('You are not root!')

else

Writeln('Chmod failed with exit code: ',LinuxError)

else

Writeln('Changed owner successfully!');

end.

 

13.44. mkdir.

Program Tabs;

begin

{$I-}

if ParamCount=1 then

begin

MkDir(ParamStr(1));

if IOResult <> 0 then Writeln('Cannot create directory')

else Writeln('New directory created');

end

else Writeln('Error');

end.

 

13.45. chmod.

uses linux;

var

f,ch:string;

n,i:byte;

d:integer;

begin

if paramcount<>2 then

begin

writeln(': ',paramstr(0),' _ /');

exit;

end;

f:=paramstr(2);

ch:=paramstr(1);

n:=length(ch);

d:=0;

for i:=1 to n do

if not (ch[i] in ['0'..'7']) then

begin

writeln(' ');

exit;

end

else

d:=d*8+byte(ch[i])-byte('0');

if not chmod(f,d) then

writeln(' ',ch,' ',f);

end.

13.46. chown.

uses linux,strings,sysutils,crt;

type

plong=^longint;

procedure perror(s:pchar);cdecl;external 'c';

function strchr(s:string;c:char):boolean;

var

i:integer;

begin

for i:=1 to length(s) do

if s[i]=c then

begin

strchr:=true;

exit;

end;

strchr:=false;

end;

procedure getall(w:string;name:string;var uid,gid:integer);

var ts,nam1,namb1,namb2:string;

tx:text;

d:integer;

f:boolean;

begin

assign(tx,w);

reset(tx);

f:=false;

while not EOF (tx) and not f do