Be the first to rate this file! 30 downloads (last 30 days) File Size: 2.22 KB File ID: #22209

genpath_exclude

by Jesse Hopkins

 

21 Nov 2008 (Updated 27 Oct 2009)

Code covered by BSD License  

Executes like genpath, but can ignore specified directories.

Download Now | Watch this File

File Information
Description

Executes like genpath, but can ignore directories. Useful to add a directory hierarchy to your path, but ignore CM directories such as "CVS" or ".svn"

Directories may be excluded using regular-expressions as well.

Tested on windows only, but should work on any platform.

Example usage:
genpath_exclude('C:\myDir',{'CVS'}) %<--- simple usage to ignore CVS direcotries

genpath_exclude('C:\myDir',{'\.svn'}) %<--- simple usage to ignore .svn (note that "." must be escaped for proper handling in the regexp)

genpath_exclude('C:\myDir',{'CVS','#.*'}) %<----more advanced usage to ignore CVS directories and any directory starting with "#"

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
Recursive addpath

MATLAB release MATLAB 7.5 (R2007b)
Zip File Content  
Other Files genpath_exclude.m,
license.txt
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (2)
25 Nov 2008 Thierry Dalon

I think regexp with option 'split' is quite new.=>This may not work with R14 or previous.
For optimization why don't you modify directly genpath to not go into excluded directories?

25 Nov 2008 Jesse Hopkins

Thanks for the comment Thierry. I did look at modifying genpath, and for some reason on my first attempt, the excluded path would still be added, but not the tree beneath it. That is when I went off looking into the regexp business to remove the offending paths.

Taking a second look, I realize that it is possible to modify genpath directly accomplish this goal, which should operate faster since it wouldn't recurse on the ignored directories.

Please login to add a comment or rating.
Updates
25 Nov 2008

Updated file so that it is a modified version of genpath, rather than post-processing the output of genpath.

25 Nov 2008

Made input more robust so that if user enters a string as 'excudeDir' rather than a cell array of strings this function will still work.

11 Dec 2008

Updated description.

27 Oct 2009

fixed regexp handling. wrapped each expression in ^ and $ chars. Added more help comments

Tag Activity for this File
Tag Applied By Date/Time
svn Jesse Hopkins 24 Nov 2008 13:42:59
cvs Jesse Hopkins 24 Nov 2008 13:42:59
path Jesse Hopkins 24 Nov 2008 13:42:59
cm Jesse Hopkins 24 Nov 2008 13:42:59
cvs Linda 06 Apr 2009 12:37:15
cm Linda 06 Apr 2009 12:37:15
path Linda 06 Apr 2009 12:37:16
svn Linda 06 Apr 2009 12:37:17
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com