1 %> @ingroup misc introspection
3 %>@brief Recursive directory structure getter
5 %> @param direc A directory to query all subdirectories from
6 %> @param list (optional) An existing list to which new elements will be appended
7 %> @param patt_match If specified, directories will have to match this pattern
8 %> @param patt_exclude If specified, directories will have NOT TO match this pattern
10 function list =
getdirs(direc, list, patt_match, patt_exclude)
12 if nargin < 1 || isempty(direc)
16 if nargin < 2 || isempty(list)
26 flag_match = ~isempty(patt_match);
27 flag_exclude = ~isempty(patt_exclude);
30 d = {d([d.isdir]).name};
31 d = {d{~ismember(d,{
'.' '..'})}};
33 d = d(cellfun(@(x) ~isempty(x), regexp(d, patt_match,
'start')));
36 d = d(cellfun(@isempty, regexp(d, patt_exclude,
'start')));
39 if ~any(d{j}(1) ==
'@.')
40 ff = fullfile(direc,d{j});
42 list =
getdirs(ff,list, patt_match, patt_exclude);
function getdirs(in direc, in list, in patt_match, in patt_exclude)