wolffd@0
|
1 function p = genpathKPM(d)
|
wolffd@0
|
2 % genpathKPM Like built-in genpath, but omits directories whose name is 'Old', 'old' or 'CVS'
|
wolffd@0
|
3 % function p = genpathKPM(d)
|
wolffd@0
|
4
|
wolffd@0
|
5 if nargin==0,
|
wolffd@0
|
6 p = genpath(fullfile(matlabroot,'toolbox'));
|
wolffd@0
|
7 if length(p) > 1, p(end) = []; end % Remove trailing pathsep
|
wolffd@0
|
8 return
|
wolffd@0
|
9 end
|
wolffd@0
|
10
|
wolffd@0
|
11 % initialise variables
|
wolffd@0
|
12 methodsep = '@'; % qualifier for overloaded method directories
|
wolffd@0
|
13 p = ''; % path to be returned
|
wolffd@0
|
14
|
wolffd@0
|
15 % Generate path based on given root directory
|
wolffd@0
|
16 files = dir(d);
|
wolffd@0
|
17 if isempty(files)
|
wolffd@0
|
18 return
|
wolffd@0
|
19 end
|
wolffd@0
|
20
|
wolffd@0
|
21 % Add d to the path even if it is empty.
|
wolffd@0
|
22 p = [p d pathsep];
|
wolffd@0
|
23
|
wolffd@0
|
24 % set logical vector for subdirectory entries in d
|
wolffd@0
|
25 isdir = logical(cat(1,files.isdir));
|
wolffd@0
|
26 %
|
wolffd@0
|
27 % Recursively descend through directories which are neither
|
wolffd@0
|
28 % private nor "class" directories.
|
wolffd@0
|
29 %
|
wolffd@0
|
30 dirs = files(isdir); % select only directory entries from the current listing
|
wolffd@0
|
31
|
wolffd@0
|
32 for i=1:length(dirs)
|
wolffd@0
|
33 dirname = dirs(i).name;
|
wolffd@0
|
34 if ~strcmp( dirname,'.') & ...
|
wolffd@0
|
35 ~strcmp( dirname,'..') & ...
|
wolffd@0
|
36 ~strcmp( dirname,'.svn') & ...
|
wolffd@0
|
37 ~strncmp( dirname,methodsep,1)& ...
|
wolffd@0
|
38 ~strcmp( dirname,'private') & ...
|
wolffd@0
|
39 ~strcmp( dirname, 'CVS') & ...
|
wolffd@0
|
40 isempty(strfind(dirname, 'Old')) & ...
|
wolffd@0
|
41 isempty(strfind(dirname, 'old'))
|
wolffd@0
|
42 p = [p genpathKPM(fullfile(d,dirname))]; % recursive calling of this function.
|
wolffd@0
|
43 end
|
wolffd@0
|
44 end
|
wolffd@0
|
45
|
wolffd@0
|
46 %------------------------------------------------------------------------------
|