UNIX Free Pascal


. - 12


strcat(polniypath,el^.name);

end;

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

writeln(' stat ',polniypath)

else

begin

if S_ISDIR(st.mode) then

begin

if (strcomp(el^.name,'.')<>0) and (strcomp(el^.name,'..')<>0) then

begin

writeln;

writeln(polniypath,':');

obhod(polniypath);

end;

end;

end;

el:=readdir(d);

end;

closedir(d);

 

 

end;

 

var

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

begin

if paramcount = 0 then

name:='.'

else

name:=paramstr(1);

obhod(name);

 

end.

 

13.33. , , , .

uses linux,strings,sysutils,crt;

 

{$linklib c}

 

type

plong=^longint;

 

 

 

function gettype(mode:integer):char;

begin

if S_ISREG(mode) then

gettype:='-'

else

if S_ISDIR(mode) then

gettype:='d'

else

if S_ISCHR(mode) then

gettype:='c'

else

if S_ISBLK(mode) then

gettype:='b'

else

if S_ISFIFO(mode) then

gettype:='p'

else

gettype:='l';

end;

 

 

 

function obhod(name:pchar):boolean;

var

flag:boolean;

d:PDIR;

el:pdirent;

st:stat;

res:integer;

polniypath:array [0..2000] of char;

begin

flag:=true;

d:=opendir(name);

if d=nil then

begin

writeln(' ',name);

exit;

end;

el:=readdir(d);

while el<>nil do

begin

polniypath:=name;

if strcomp(name,'/')=0 then

strcat(polniypath,el^.name)

else

begin

if name[strlen(name)-1]<>'/' then

strcat(polniypath,'/');

strcat(polniypath,el^.name);

end;

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

writeln(' stat ',polniypath)




- -  - -  - -