Rev | Line | |
---|
[9730] | 1 | function p = recursivepath(d)
|
---|
| 2 | %RECURSIVEPATH - generate paths in a directory
|
---|
[1] | 3 | %
|
---|
[13001] | 4 | % this routine is equivalent to Matlab's genpath except that it skips CVS and
|
---|
| 5 | % .svn directories
|
---|
[1] | 6 | %
|
---|
| 7 | % Usage:
|
---|
[9730] | 8 | % p = recursivepath(d)
|
---|
[1] | 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;
|
---|
[8735] | 30 | if ~strcmp(dirname,'.') & ...
|
---|
[1] | 31 | ~strcmp(dirname,'..') & ...
|
---|
[8735] | 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
|
---|
[1] | 36 |
|
---|
[9730] | 37 | p = [p recursivepath(fullfile(d,dirname))];
|
---|
[1] | 38 | end
|
---|
| 39 | end
|
---|
Note:
See
TracBrowser
for help on using the repository browser.