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