UNIX Free Pascal


. - 8


if(gettype(st.mode)='p') then

textcolor(brown);

if(gettype(st.mode)='l') then

textcolor(lightblue);

if (gettype(st.mode)='c') or (gettype(st.mode)='b') then

textcolor(yellow);

write(el^.name);

for k:=strlen(el^.name) to 15 do

write(' ');

textcolor(7);

end;

el:=readdir(d);

inc(i);

if(i mod 5=0)then writeln;

end;

closedir(d);

if(i mod 5<>0)then writeln;

 

end;

 

var

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

begin

if paramcount = 0 then

name:='.'

else

name:=paramstr(1);

obhod(name);

 

end.

 

13.31. , . .

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)




- -  - -  - -