# HG changeset patch # User Jordi GutiƩrrez Hermoso # Date 1284445118 14400 # Node ID 386aa01ca84c67685ccdbd35560ed62eef8a1141 # Parent 795400289d1c54d0d84986f6034240ed40d790e3 genpath: accept additional arguments as names of directories to skip diff -r 795400289d1c -r 386aa01ca84c src/ChangeLog --- a/src/ChangeLog Tue Sep 14 01:59:03 2010 -0400 +++ b/src/ChangeLog Tue Sep 14 02:18:38 2010 -0400 @@ -1,3 +1,8 @@ +2010-09-14 Jordi GutiƩrrez Hermoso + + * load-path.cc (genpath): Pass SKIP in recursive call. + (Fgenpath): Accept list of directories to skip. + 2010-09-14 John W. Eaton * oct-stream.cc (BEGIN_CHAR_CLASS_CONVERSION): If we hit EOF but diff -r 795400289d1c -r 386aa01ca84c src/load-path.cc --- a/src/load-path.cc Tue Sep 14 01:59:03 2010 -0400 +++ b/src/load-path.cc Tue Sep 14 02:18:38 2010 -0400 @@ -1829,10 +1829,6 @@ { std::string elt = dirlist[i]; - // FIXME -- the caller should be able to specify the list of - // directories to skip in addition to ".", "..", and - // directories beginning with "@". - bool skip_p = (elt == "." || elt == ".." || elt[0] == '@'); if (! skip_p) @@ -1851,7 +1847,7 @@ file_stat fs (nm); if (fs && fs.is_dir ()) - retval += dir_path::path_sep_str () + genpath (nm); + retval += dir_path::path_sep_str () + genpath (nm, skip); } } } @@ -1896,12 +1892,17 @@ DEFUN (genpath, args, , "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} genpath (@var{dir})\n\ +@deftypefnx {Built-in Function} {} genpath (@var{dir}, @var{skip}, @dots{})\n\ Return a path constructed from @var{dir} and all its subdirectories.\n\ +If additional string parameters are given, the resulting path will \n\ +exclude directories with those names.\ @end deftypefn") { octave_value retval; - if (args.length () == 1) + octave_idx_type nargin = args.length (); + + if (nargin == 1) { std::string dirname = args(0).string_value (); @@ -1910,6 +1911,25 @@ else error ("genpath: expecting argument to be a character string"); } + else if (nargin > 1) + { + std::string dirname = args(0).string_value (); + + string_vector skip (nargin - 1); + + for (octave_idx_type i = 1; i < nargin; i++) + { + skip[i-1] = args(i).string_value (); + + if (error_state) + break; + } + + if (! error_state) + retval = genpath (dirname, skip); + else + error ("genpath: expecting all arguments to be character strings"); + } else print_usage ();