5732
|
1 ## Copyright (C) 2000 Etienne Grossmann |
|
2 ## |
|
3 ## This program is free software; you can redistribute it and/or modify |
|
4 ## it under the terms of the GNU General Public License as published by |
|
5 ## the Free Software Foundation; either version 2 of the License, or |
|
6 ## (at your option) any later version. |
|
7 ## |
|
8 ## This program is distributed in the hope that it will be useful, |
|
9 ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 ## GNU General Public License for more details. |
|
12 ## |
|
13 ## You should have received a copy of the GNU General Public License |
|
14 ## along with this program; if not, write to the Free Software |
|
15 ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
16 |
|
17 ## -*- texinfo -*- |
5733
|
18 ## @deftypefn {Function File} {} rmpath (@var{dir1}, @dots{}) |
5814
|
19 ## Remove @var{dir1}, @dots{} from the current function search path. |
5733
|
20 ## |
5814
|
21 ## @seealso{path, addpath, genpath, pathdef, savepath, pathsep} |
5732
|
22 ## @end deftypefn |
|
23 |
5733
|
24 ## Author: Etienne Grossmann <etienne@cs.uky.edu> |
5732
|
25 |
5736
|
26 ## PKGADD: mark_as_command rmpath |
5732
|
27 |
|
28 function ret = rmpath (varargin) |
|
29 |
5804
|
30 if (nargout > 0) |
|
31 ret = path (); |
5732
|
32 endif |
|
33 |
5804
|
34 psep = pathsep (); |
5732
|
35 |
5804
|
36 xpath = cellstr (split (path (), psep)); |
|
37 n_path_elts = length (xpath); |
5732
|
38 |
5804
|
39 for i = 1:nargin |
|
40 dir_elts = cellstr (split (varargin{i}, psep)); |
|
41 n_dir_elts = length (dir_elts); |
|
42 for j = 1:n_dir_elts |
|
43 dir = regexprep (dir_elts{j}, "//+", "/"); |
|
44 dir = regexprep (dir, "/$", ""); |
|
45 elt_found = false; |
|
46 for k = n_path_elts:-1:1 |
5814
|
47 if (strcmp (dir, ".")) |
|
48 warning ("rmpath: can't remove \".\" from path"); |
|
49 elseif (strcmp (dir, xpath{k})) |
|
50 xpath(k) = []; |
5804
|
51 n_path_elts--; |
|
52 elt_found = true; |
|
53 endif |
|
54 endfor |
|
55 if (! elt_found) |
|
56 warning ("rmpath: %s: not found", dir); |
|
57 endif |
|
58 endfor |
|
59 endfor |
5732
|
60 |
5814
|
61 ## Ensure a 1xN cell array. |
|
62 xpath = xpath(:)'; |
|
63 |
|
64 xpath{2,:} = psep; |
|
65 xpath{2,end} = ""; |
5804
|
66 |
|
67 tmp = strcat (xpath{:}); |
|
68 |
|
69 path (tmp); |
5732
|
70 |
|
71 endfunction |