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

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

CHG:moved recursivepath to os

File size: 1.0 KB
RevLine 
[9730]1function 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
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;
[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
39end
Note: See TracBrowser for help on using the repository browser.