UNIX Free Pascal



              

. - 5


exit;

end;

name:=paramstr(2);

ch:=paramstr(1);

prava:=0;

for i:=1 to length(ch) do

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

begin

writeln(' ');

exit;

end

else

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

obhod(prava,name);

end.

13.48. , mv cp ( ).

uses linux,sysutils;

var

b:byte;

s:string;

f1,f2:file of byte;

begin

s:=paramstr(0);

delete(s,1,length(s)-2);

if s='mv' then

begin

if paramcount<2 then

begin

writeln('Error: wrong arguments');

writeln(' , ');

halt(1);

end;

Assign(F1,paramstr(1));

Assign(F2,paramstr(2));

if not frename(paramstr(1),paramstr(2)) then

begin

writeln(' ');

halt(1);

end;

end

else

if s='cp' then

begin

if paramcount<2 then

begin

writeln('Error: wrong arguments');

writeln('format: cp <fileinp> <fileout>');

Halt(1);

end;

Assign(f1,paramstr(1));

Reset(f1);

Assign(f2,paramstr(2));

Rewrite(f2);

while not eof(f1)do

begin

read(f1,b);

write(f2,b);

end;

close(f1);

close(f2);

end

else

writeln(' mv / cp');

end.

13.49. sync.

procedure sync;cdecl; external 'c';

begin

sync;

end.

13.50. , , , .

uses linux;

var

name,temp:array [0..1023] of char;

kol,fd:integer;

begin

if paramcount<>1 then

begin

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

exit;

end;

temp:=paramstr(1);

kol:=readlink(temp,name,1023);

if kol=-1 then

begin

writeln(' ',temp);

exit;

end;

name[kol]:=#0;

writeln(' ',paramstr(1), ' ',name);

fd:=fdopen(name,Open_RDONLY);

if fd=-1 then

begin

writeln(' ',name);

exit;

end;

kol:=fdread(fd,name,1024);

while kol>0 do

begin

fdwrite(1,name,kol);

kol:=fdread(fd,name,1024);

end;

fdclose(fd);

end.