Line | |
---|
1 | function p = recursivepath(d)
|
---|
2 | %RECURSIVEPATH - generate paths in a directory
|
---|
3 | %
|
---|
4 | % this routine is equivalent to Matlab's genpath except that it skips CVS and
|
---|
5 | % .svn directories
|
---|
6 | %
|
---|
7 | % Usage:
|
---|
8 | % p = recursivepath(d)
|
---|
9 |
|
---|
10 | %initialize path to be returned
|
---|
11 | p = '';
|
---|
12 | sep=pathsep; %directory separator
|
---|
13 |
|
---|
14 | % Generate path based on given root directory
|
---|
15 | files=dir(d);
|
---|
16 | if isempty(files)
|
---|
17 | return
|
---|
18 | end
|
---|
19 |
|
---|
20 | % Add d to the path even if it is empty.
|
---|
21 | p = [p d sep];
|
---|
22 |
|
---|
23 | % set logical vector for subdirectory entries in d
|
---|
24 | isdir = logical(cat(1,files.isdir));
|
---|
25 |
|
---|
26 | % Recursively goes through the subdirectories of d
|
---|
27 | dirs=files(isdir); % select only directory entries from the current listing
|
---|
28 | for i=1:length(dirs)
|
---|
29 | dirname=dirs(i).name;
|
---|
30 | if ~strcmp(dirname,'.') & ...
|
---|
31 | ~strcmp(dirname,'..') & ...
|
---|
32 | ~strcmp(dirname,'.svn') & ...
|
---|
33 | ~strcmp(dirname,'CVS') & ...
|
---|
34 | ~strncmp(dirname,'@',1) & ... %Method directories not allowed in MATLAB path
|
---|
35 | ~strcmp(dirname,'private') %private directories not allowed in MATLAB path
|
---|
36 |
|
---|
37 | p = [p recursivepath(fullfile(d,dirname))];
|
---|
38 | end
|
---|
39 | end
|
---|
Note:
See
TracBrowser
for help on using the repository browser.