matthiasm@8: function p = genpathKPM(d) matthiasm@8: % genpathKPM Like built-in genpath, but omits directories whose name is 'Old', 'old' or 'CVS' matthiasm@8: % function p = genpathKPM(d) matthiasm@8: matthiasm@8: if nargin==0, matthiasm@8: p = genpath(fullfile(matlabroot,'toolbox')); matthiasm@8: if length(p) > 1, p(end) = []; end % Remove trailing pathsep matthiasm@8: return matthiasm@8: end matthiasm@8: matthiasm@8: % initialise variables matthiasm@8: methodsep = '@'; % qualifier for overloaded method directories matthiasm@8: p = ''; % path to be returned matthiasm@8: matthiasm@8: % Generate path based on given root directory matthiasm@8: files = dir(d); matthiasm@8: if isempty(files) matthiasm@8: return matthiasm@8: end matthiasm@8: matthiasm@8: % Add d to the path even if it is empty. matthiasm@8: p = [p d pathsep]; matthiasm@8: matthiasm@8: % set logical vector for subdirectory entries in d matthiasm@8: isdir = logical(cat(1,files.isdir)); matthiasm@8: % matthiasm@8: % Recursively descend through directories which are neither matthiasm@8: % private nor "class" directories. matthiasm@8: % matthiasm@8: dirs = files(isdir); % select only directory entries from the current listing matthiasm@8: matthiasm@8: for i=1:length(dirs) matthiasm@8: dirname = dirs(i).name; matthiasm@8: if ~strcmp( dirname,'.') & ... matthiasm@8: ~strcmp( dirname,'..') & ... matthiasm@8: ~strncmp( dirname,methodsep,1)& ... matthiasm@8: ~strcmp( dirname,'private') & ... matthiasm@8: ~strcmp( dirname, 'old') & ... % KPM matthiasm@8: ~strcmp( dirname, 'Old') & ... % KPM matthiasm@8: ~strcmp( dirname, 'CVS') % KPM matthiasm@8: p = [p genpathKPM(fullfile(d,dirname))]; % recursive calling of this function. matthiasm@8: end matthiasm@8: end matthiasm@8: matthiasm@8: %------------------------------------------------------------------------------