source: issm/trunk-jpl/src/m/os/recursivepath.m

Last change on this file was 13001, checked in by Mathieu Morlighem, 13 years ago

CHG:moved recursivepath to os

File size: 1.0 KB
Line 
1function 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
11p = '';
12sep=pathsep; %directory separator
13
14% Generate path based on given root directory
15files=dir(d);
16if isempty(files)
17 return
18end
19
20% Add d to the path even if it is empty.
21p = [p d sep];
22
23% set logical vector for subdirectory entries in d
24isdir = logical(cat(1,files.isdir));
25
26% Recursively goes through the subdirectories of d
27dirs=files(isdir); % select only directory entries from the current listing
28for 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
39end
Note: See TracBrowser for help on using the repository browser.