UNIX Free Pascal



              

. - 4


st:stat;

res:integer;

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

ch:string;

n,i:byte;

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)

else

begin

//if not (gettype(st.mode) = 'd') then

if not chmod(pchar(polniypath),prava) then

writeln(' ',prava,' ',polniypath);

end;

el:=readdir(d);

end;

closedir(d);

d:=opendir(name);

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)

else

begin

if (gettype(st.mode)='d') and

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

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

begin

writeln(' ',polniypath);

if not obhod(prava,polniypath) then

flag:=false;

end;

end;

el:=readdir(d);

end;

closedir(d);

if not flag then

writeln(' ',name, ' ');

// writeln(' ',name, ' ',flag);

obhod:=flag;

end;

var

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

prava,i:integer;

ch:string;

begin

if paramcount<>2 then

begin

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