Mercurial > hg > ishara
view general/fileutils/frecurse.m @ 61:eff6bddf82e3 tip
Finally implemented perceptual brightness thing.
author | samer |
---|---|
date | Sun, 11 Oct 2015 10:20:42 +0100 |
parents | 47cb292350f3 |
children |
line wrap: on
line source
function frecurse(fn,dirname,level) % frecurse: recursively descend a directory tree % % frecurse :: % (string ~'directory name',natural~'level'=>bool~'descend into?') ~'fn to process directory, % string ~'directory to start from, % natural ~'initial level assigned to start directory' % => void. % % usage: frecurse(<function>,<dirname>[,<level0>]) % % traverses directory tree, starting at <dirname>, % and calling the named <function> for each directory. % <function> must be of the form: % flag=<function>(<thisdirname>,<level>) % <level> indicates how many directory levels down from % the original directory <thisdirname> is. % if <flag> is 1, recurse will descend into that directory if nargin<2, dirname=''; end if nargin<3, level=0; end if fn(dirname,level) list=dir(dirname); for k=1:length(list) name=[dirname '/' list(k).name]; if list(k).isdir & list(k).name(1)~='.' disp(['--- descending into ' name]); recurse(fn,name,level+1); end end end