UNIX Free Pascal



              

.


13.41. rm.

uses linux,sysutils;

var

f:text;

d:boolean;

k:char;

s:string;

begin

writeln(' , ');

readln(s);

assign(f,s);

if s='' then

begin

writeln(' ');

exit;

end;

writeln(' Y/N');

readln(k);

if (k='Y') or (k='y') then

begin

d:=deletefile(s);

if d then

writeln(' ')

else

writeln(' ');

end

else

writeln(' ');

end.

 

13.42. fstat, , : , , , FIFO-.

uses linux,strings,sysutils;

function gettype(mode:integer):string;

begin

if S_ISREG(mode) then

gettype:=''

else

if S_ISDIR(mode) then

gettype:=''

else

if S_ISCHR(mode) then

gettype:=' '

else

if S_ISBLK(mode) then

gettype:=' '

else

if S_ISFIFO(mode) then

gettype:='FIFO-'

else

gettype:='';

end;

var

st:stat;

name:array[0..255] of char;

begin

if paramcount = 0 then

name:='.'

else

name:=fexpand(paramstr(1));

if not fstat(pchar(name),st) then

writeln(' stat ',name)

else

write(gettype(st.mode));

end.

 

13.43. chgrp.

Uses linux;

Var

UID,GID:Longint;

F:Text;

Code:Integer;

begin

Writeln('This will only work if you are root.');

if ParamCount<3 then

begin

Writeln('Error!!!');

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

Halt(1);

end;

val(Paramstr(2),UID,Code);

if Code<>0 then

begin

Writeln('Error!!!');

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