5832
|
1 /* |
|
2 |
|
3 Copyright (C) 2006 John W. Eaton |
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
|
19 Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
20 02110-1301, USA. |
|
21 |
|
22 */ |
|
23 |
|
24 #ifdef HAVE_CONFIG_H |
|
25 #include <config.h> |
|
26 #endif |
|
27 |
|
28 #include <algorithm> |
|
29 |
|
30 #include "dir-ops.h" |
|
31 #include "file-ops.h" |
|
32 #include "file-stat.h" |
|
33 #include "oct-env.h" |
|
34 #include "pathsearch.h" |
|
35 |
|
36 #include "defaults.h" |
|
37 #include "defun.h" |
|
38 #include "input.h" |
|
39 #include "load-path.h" |
|
40 #include "pager.h" |
|
41 #include "parse.h" |
|
42 #include "toplev.h" |
|
43 #include "unwind-prot.h" |
|
44 #include "utils.h" |
|
45 |
|
46 load_path *load_path::instance = 0; |
|
47 load_path::hook_function_ptr load_path::add_hook = execute_pkg_add; |
|
48 load_path::hook_function_ptr load_path::remove_hook = execute_pkg_del; |
|
49 std::string load_path::command_line_path; |
|
50 |
|
51 static std::string Vsystem_path; |
|
52 |
|
53 void |
|
54 load_path::dir_info::update (void) |
|
55 { |
|
56 if (is_relative) |
|
57 initialize (); |
|
58 else |
|
59 { |
|
60 file_stat fs (dir_name); |
|
61 |
|
62 if (fs) |
|
63 { |
|
64 if (fs.mtime () != dir_mtime) |
|
65 initialize (); |
|
66 } |
|
67 else |
|
68 { |
|
69 std::string msg = fs.error (); |
|
70 warning ("load_path: %s: %s", dir_name.c_str (), msg.c_str ()); |
|
71 } |
|
72 } |
|
73 } |
|
74 |
|
75 void |
|
76 load_path::dir_info::initialize (void) |
|
77 { |
|
78 is_relative = ! octave_env::absolute_pathname (dir_name); |
|
79 |
|
80 file_stat fs (dir_name); |
|
81 |
|
82 if (fs) |
|
83 { |
|
84 dir_mtime = fs.mtime (); |
|
85 |
|
86 bool has_private_subdir = get_file_list (dir_name); |
|
87 |
|
88 if (! error_state) |
|
89 { |
|
90 if (has_private_subdir) |
|
91 { |
|
92 std::string pdn = dir_name + file_ops::dir_sep_str + "private"; |
|
93 |
|
94 get_private_function_map (pdn); |
|
95 } |
|
96 } |
|
97 } |
|
98 else |
|
99 { |
|
100 std::string msg = fs.error (); |
|
101 warning ("load_path: %s: %s", dir_name.c_str (), msg.c_str ()); |
|
102 } |
|
103 } |
|
104 |
|
105 bool |
|
106 load_path::dir_info::get_file_list (const std::string& d) |
|
107 { |
|
108 bool has_private_subdir = false; |
|
109 |
|
110 dir_entry dir (d); |
|
111 |
|
112 if (dir) |
|
113 { |
|
114 string_vector flist = dir.read (); |
|
115 |
|
116 octave_idx_type len = flist.length (); |
|
117 |
|
118 all_files.resize (len); |
|
119 fcn_files.resize (len); |
|
120 |
|
121 octave_idx_type all_files_count = 0; |
|
122 octave_idx_type fcn_files_count = 0; |
|
123 |
|
124 for (octave_idx_type i = 0; i < len; i++) |
|
125 { |
|
126 std::string fname = flist[i]; |
|
127 |
|
128 std::string full_name = d + file_ops::dir_sep_str + fname; |
|
129 |
|
130 file_stat fs (full_name); |
|
131 |
|
132 if (fs) |
|
133 { |
|
134 if (fs.is_dir ()) |
|
135 { |
|
136 if (! has_private_subdir && fname == "private") |
|
137 has_private_subdir = true; |
|
138 } |
|
139 else |
|
140 { |
|
141 all_files[all_files_count++] = fname; |
|
142 |
|
143 size_t pos = fname.rfind ('.'); |
|
144 |
|
145 if (pos != NPOS) |
|
146 { |
|
147 std::string ext = fname.substr (pos); |
|
148 |
5864
|
149 if (ext == ".m" || ext == ".oct" || ext == ".mex") |
5832
|
150 { |
|
151 std::string base = fname.substr (0, pos); |
|
152 |
|
153 if (valid_identifier (base)) |
|
154 fcn_files[fcn_files_count++] = fname; |
|
155 } |
|
156 } |
|
157 } |
|
158 } |
|
159 } |
|
160 |
|
161 all_files.resize (all_files_count); |
|
162 fcn_files.resize (fcn_files_count); |
|
163 } |
|
164 else |
|
165 { |
|
166 std::string msg = dir.error (); |
|
167 warning ("load_path: %s: %s", d.c_str (), msg.c_str ()); |
|
168 } |
|
169 |
|
170 return has_private_subdir; |
|
171 } |
|
172 |
|
173 void |
|
174 load_path::dir_info::get_private_function_map (const std::string& d) |
|
175 { |
|
176 dir_entry dir (d); |
|
177 |
|
178 if (dir) |
|
179 { |
|
180 string_vector flist = dir.read (); |
|
181 |
|
182 octave_idx_type len = flist.length (); |
|
183 |
|
184 for (octave_idx_type i = 0; i < len; i++) |
|
185 { |
|
186 std::string fname = flist[i]; |
|
187 |
|
188 std::string ext; |
|
189 std::string base = fname; |
|
190 |
|
191 size_t pos = fname.rfind ('.'); |
|
192 |
|
193 if (pos != NPOS) |
|
194 { |
|
195 base = fname.substr (0, pos); |
|
196 ext = fname.substr (pos); |
|
197 |
|
198 if (valid_identifier (base)) |
|
199 { |
|
200 int t = 0; |
|
201 |
|
202 if (ext == ".m") |
|
203 t = load_path::M_FILE; |
|
204 else if (ext == ".oct") |
|
205 t = load_path::OCT_FILE; |
5864
|
206 else if (ext == ".mex") |
|
207 t = load_path::MEX_FILE; |
5832
|
208 |
|
209 private_function_map[base] |= t; |
|
210 } |
|
211 } |
|
212 } |
|
213 } |
|
214 else |
|
215 { |
|
216 std::string msg = dir.error (); |
|
217 warning ("load_path: %s: %s", d.c_str (), msg.c_str ()); |
|
218 } |
|
219 } |
|
220 |
|
221 bool |
|
222 load_path::instance_ok (void) |
|
223 { |
|
224 bool retval = true; |
|
225 |
|
226 if (! instance) |
|
227 instance = new load_path (); |
|
228 |
|
229 if (! instance) |
|
230 { |
|
231 ::error ("unable to create load path object!"); |
|
232 |
|
233 retval = false; |
|
234 } |
|
235 |
|
236 return retval; |
|
237 } |
|
238 |
|
239 load_path::const_dir_info_list_iterator |
5919
|
240 load_path::find_dir_info (const std::string& dir_arg) const |
5832
|
241 { |
5919
|
242 std::string dir = file_ops::tilde_expand (dir_arg); |
|
243 |
5832
|
244 const_dir_info_list_iterator retval = dir_info_list.begin (); |
|
245 |
|
246 while (retval != dir_info_list.end ()) |
|
247 { |
|
248 if (retval->dir_name == dir) |
|
249 break; |
|
250 |
|
251 retval++; |
|
252 } |
|
253 |
|
254 return retval; |
|
255 } |
|
256 |
|
257 load_path::dir_info_list_iterator |
5919
|
258 load_path::find_dir_info (const std::string& dir_arg) |
5832
|
259 { |
5919
|
260 std::string dir = file_ops::tilde_expand (dir_arg); |
|
261 |
5832
|
262 dir_info_list_iterator retval = dir_info_list.begin (); |
|
263 |
|
264 while (retval != dir_info_list.end ()) |
|
265 { |
|
266 if (retval->dir_name == dir) |
|
267 break; |
|
268 |
|
269 retval++; |
|
270 } |
|
271 |
|
272 return retval; |
|
273 } |
|
274 |
|
275 bool |
|
276 load_path::contains (const std::string& dir) const |
|
277 { |
|
278 return find_dir_info (dir) != dir_info_list.end (); |
|
279 } |
|
280 |
|
281 void |
|
282 load_path::move (dir_info_list_iterator i, bool at_end) |
|
283 { |
|
284 if (dir_info_list.size () > 1) |
|
285 { |
|
286 dir_info di = *i; |
|
287 |
|
288 dir_info_list.erase (i); |
|
289 |
|
290 if (at_end) |
|
291 dir_info_list.push_back (di); |
|
292 else |
|
293 dir_info_list.push_front (di); |
|
294 |
|
295 std::string dir = di.dir_name; |
|
296 |
|
297 string_vector fcn_files = di.fcn_files; |
|
298 |
|
299 octave_idx_type len = fcn_files.length (); |
|
300 |
|
301 for (octave_idx_type k = 0; k < len; k++) |
|
302 { |
|
303 std::string fname = fcn_files[k]; |
|
304 |
|
305 std::string ext; |
|
306 std::string base = fname; |
|
307 |
|
308 size_t pos = fname.rfind ('.'); |
|
309 |
|
310 if (pos != NPOS) |
|
311 { |
|
312 base = fname.substr (0, pos); |
|
313 ext = fname.substr (pos); |
|
314 } |
|
315 |
|
316 std::list<file_info>& file_info_list = fcn_map[base]; |
|
317 |
|
318 if (file_info_list.size () == 1) |
|
319 continue; |
|
320 else |
|
321 { |
|
322 for (std::list<file_info>::iterator p = file_info_list.begin (); |
|
323 p != file_info_list.end (); |
|
324 p++) |
|
325 { |
|
326 if (p->dir_name == dir) |
|
327 { |
|
328 file_info& fi = *p; |
|
329 |
|
330 file_info_list.erase (p); |
|
331 |
|
332 if (at_end) |
|
333 file_info_list.push_back (fi); |
|
334 else |
|
335 file_info_list.push_front (fi); |
|
336 |
|
337 break; |
|
338 } |
|
339 } |
|
340 } |
|
341 } |
|
342 } |
|
343 } |
|
344 |
|
345 static void |
|
346 maybe_add_path_elts (std::string& path, const std::string& dir) |
|
347 { |
|
348 std::string tpath = genpath (dir); |
|
349 |
|
350 if (! tpath.empty ()) |
|
351 path += dir_path::path_sep_str + tpath; |
|
352 } |
|
353 |
|
354 void |
|
355 load_path::do_initialize (void) |
|
356 { |
|
357 Vsystem_path = ":"; |
|
358 |
|
359 maybe_add_path_elts (Vsystem_path, Vlocal_ver_oct_file_dir); |
|
360 maybe_add_path_elts (Vsystem_path, Vlocal_api_oct_file_dir); |
|
361 maybe_add_path_elts (Vsystem_path, Vlocal_oct_file_dir); |
|
362 maybe_add_path_elts (Vsystem_path, Vlocal_ver_fcn_file_dir); |
|
363 maybe_add_path_elts (Vsystem_path, Vlocal_api_fcn_file_dir); |
|
364 maybe_add_path_elts (Vsystem_path, Vlocal_fcn_file_dir); |
|
365 maybe_add_path_elts (Vsystem_path, Voct_file_dir); |
|
366 maybe_add_path_elts (Vsystem_path, Vfcn_file_dir); |
|
367 |
|
368 std::string tpath = load_path::command_line_path; |
|
369 |
|
370 if (tpath.empty ()) |
|
371 tpath = octave_env::getenv ("OCTAVE_LOADPATH"); |
|
372 |
|
373 std::string xpath = "."; |
|
374 |
|
375 if (! tpath.empty ()) |
|
376 xpath += dir_path::path_sep_str + tpath; |
|
377 |
|
378 if (Vsystem_path != ":") |
|
379 xpath += Vsystem_path; |
|
380 |
5867
|
381 do_set (xpath + ":::", false); |
5832
|
382 } |
|
383 |
|
384 void |
|
385 load_path::do_clear (void) |
|
386 { |
|
387 dir_info_list.clear (); |
|
388 fcn_map.clear (); |
5867
|
389 |
|
390 do_append (".", false); |
5832
|
391 } |
|
392 |
|
393 static std::list<std::string> |
|
394 split_path (const std::string& p) |
|
395 { |
|
396 std::list<std::string> retval; |
|
397 |
|
398 size_t beg = 0; |
|
399 size_t end = p.find (dir_path::path_sep_char); |
|
400 |
|
401 size_t len = p.length (); |
|
402 |
|
403 while (end != NPOS) |
|
404 { |
|
405 std::string elt = p.substr (beg, end-beg); |
|
406 |
|
407 if (! elt.empty ()) |
|
408 retval.push_back (elt); |
|
409 |
|
410 beg = end + 1; |
|
411 |
|
412 if (beg == len) |
|
413 break; |
|
414 |
|
415 end = p.find (dir_path::path_sep_char, beg); |
|
416 } |
|
417 |
|
418 std::string elt = p.substr (beg); |
|
419 |
|
420 if (! elt.empty ()) |
|
421 retval.push_back (elt); |
|
422 |
|
423 return retval; |
|
424 } |
|
425 |
|
426 void |
5867
|
427 load_path::do_set (const std::string& p, bool warn) |
5832
|
428 { |
|
429 do_clear (); |
|
430 |
|
431 std::list<std::string> elts = split_path (p); |
|
432 |
|
433 // Temporarily disable add hook. |
|
434 |
5854
|
435 unwind_protect_fptr (add_hook); |
5832
|
436 |
|
437 add_hook = 0; |
|
438 |
|
439 for (std::list<std::string>::const_iterator i = elts.begin (); |
|
440 i != elts.end (); |
|
441 i++) |
5867
|
442 do_append (*i, warn); |
5832
|
443 |
|
444 // Restore add hook and execute for all newly added directories. |
|
445 |
|
446 unwind_protect::run (); |
|
447 |
|
448 for (dir_info_list_iterator i = dir_info_list.begin (); |
|
449 i != dir_info_list.end (); |
|
450 i++) |
|
451 { |
|
452 if (add_hook) |
|
453 add_hook (i->dir_name); |
|
454 } |
|
455 } |
|
456 |
|
457 void |
5867
|
458 load_path::do_append (const std::string& dir, bool warn) |
5832
|
459 { |
|
460 if (! dir.empty ()) |
5867
|
461 do_add (dir, true, warn); |
|
462 } |
5832
|
463 |
5867
|
464 void |
|
465 load_path::do_prepend (const std::string& dir, bool warn) |
|
466 { |
|
467 if (! dir.empty ()) |
|
468 do_add (dir, false, warn); |
5832
|
469 } |
|
470 |
|
471 void |
5919
|
472 load_path::do_add (const std::string& dir_arg, bool at_end, bool warn) |
5832
|
473 { |
5919
|
474 size_t len = dir_arg.length (); |
5911
|
475 |
5919
|
476 if (len > 1 && dir_arg.substr (len-2) == "//") |
5911
|
477 warning_with_id ("Octave:recursive-path-search", |
|
478 "trailing `//' is no longer special in search path elements"); |
|
479 |
5919
|
480 std::string dir = file_ops::tilde_expand (dir_arg); |
|
481 |
5867
|
482 dir_info_list_iterator i = find_dir_info (dir); |
|
483 |
|
484 if (i != dir_info_list.end ()) |
|
485 move (i, at_end); |
|
486 else |
5832
|
487 { |
5867
|
488 file_stat fs (dir); |
5832
|
489 |
5867
|
490 if (fs) |
5832
|
491 { |
5867
|
492 if (fs.is_dir ()) |
|
493 { |
|
494 dir_info di (dir); |
5832
|
495 |
5867
|
496 if (! error_state) |
|
497 { |
|
498 if (at_end) |
|
499 dir_info_list.push_back (di); |
|
500 else |
|
501 dir_info_list.push_front (di); |
|
502 |
|
503 add_to_fcn_map (di, true); |
5832
|
504 |
5867
|
505 if (add_hook) |
|
506 add_hook (dir); |
|
507 } |
5832
|
508 } |
5867
|
509 else if (warn) |
5919
|
510 warning ("addpath: %s: not a directory", dir_arg.c_str ()); |
5832
|
511 } |
5867
|
512 else if (warn) |
|
513 { |
|
514 std::string msg = fs.error (); |
5919
|
515 warning ("addpath: %s: %s", dir_arg.c_str (), msg.c_str ()); |
5867
|
516 } |
|
517 } |
5832
|
518 |
5867
|
519 // FIXME -- is there a better way to do this? |
5832
|
520 |
5867
|
521 i = find_dir_info ("."); |
5832
|
522 |
5867
|
523 if (i != dir_info_list.end ()) |
5871
|
524 move (i, false); |
5867
|
525 else |
|
526 panic_impossible (); |
5832
|
527 } |
|
528 |
|
529 bool |
5919
|
530 load_path::do_remove (const std::string& dir_arg) |
5832
|
531 { |
|
532 bool retval = false; |
|
533 |
5919
|
534 if (! dir_arg.empty ()) |
5832
|
535 { |
5919
|
536 if (dir_arg == ".") |
5867
|
537 { |
|
538 warning ("rmpath: can't remove \".\" from path"); |
5832
|
539 |
5867
|
540 // Avoid additional warnings. |
5832
|
541 retval = true; |
5867
|
542 } |
|
543 else |
|
544 { |
5919
|
545 std::string dir = file_ops::tilde_expand (dir_arg); |
|
546 |
5867
|
547 dir_info_list_iterator i = find_dir_info (dir); |
5832
|
548 |
5867
|
549 if (i != dir_info_list.end ()) |
|
550 { |
|
551 retval = true; |
5832
|
552 |
5867
|
553 string_vector fcn_files = i->fcn_files; |
|
554 |
|
555 dir_info_list.erase (i); |
5832
|
556 |
5867
|
557 octave_idx_type len = fcn_files.length (); |
|
558 |
|
559 for (octave_idx_type k = 0; k < len; k++) |
|
560 { |
|
561 std::string fname = fcn_files[k]; |
5832
|
562 |
5867
|
563 std::string ext; |
|
564 std::string base = fname; |
|
565 |
|
566 size_t pos = fname.rfind ('.'); |
5832
|
567 |
5867
|
568 if (pos != NPOS) |
|
569 { |
|
570 base = fname.substr (0, pos); |
|
571 ext = fname.substr (pos); |
|
572 } |
|
573 |
|
574 std::list<file_info>& file_info_list = fcn_map[base]; |
5832
|
575 |
5867
|
576 for (std::list<file_info>::iterator p = file_info_list.begin (); |
|
577 p != file_info_list.end (); |
|
578 p++) |
|
579 { |
|
580 if (p->dir_name == dir) |
|
581 { |
|
582 file_info_list.erase (p); |
5832
|
583 |
5867
|
584 if (file_info_list.empty ()) |
|
585 fcn_map.erase (fname); |
|
586 |
|
587 break; |
|
588 } |
|
589 } |
5832
|
590 } |
|
591 |
5867
|
592 if (remove_hook) |
|
593 remove_hook (dir); |
5832
|
594 } |
|
595 } |
|
596 } |
|
597 |
|
598 return retval; |
|
599 } |
|
600 |
|
601 void |
|
602 load_path::do_update (void) const |
|
603 { |
|
604 // I don't see a better way to do this because we need to |
|
605 // preserve the correct directory ordering for new files that |
|
606 // have appeared. |
|
607 |
|
608 fcn_map.clear (); |
|
609 |
|
610 for (dir_info_list_iterator p = dir_info_list.begin (); |
|
611 p != dir_info_list.end (); |
|
612 p++) |
|
613 { |
|
614 dir_info& di = *p; |
|
615 |
|
616 di.update (); |
|
617 |
|
618 add_to_fcn_map (di, true); |
|
619 } |
|
620 } |
|
621 |
|
622 std::string |
|
623 load_path::do_find_fcn (const std::string& fcn, int type) const |
|
624 { |
|
625 std::string retval; |
|
626 |
|
627 update (); |
|
628 |
|
629 const_fcn_map_iterator p = fcn_map.find (fcn); |
|
630 |
|
631 if (p != fcn_map.end ()) |
|
632 { |
|
633 const std::list<file_info>& file_info_list = p->second; |
|
634 |
|
635 for (const_file_info_list_iterator i = file_info_list.begin (); |
|
636 i != file_info_list.end (); |
|
637 i++) |
|
638 { |
|
639 const file_info& fi = *i; |
|
640 |
|
641 int t = fi.types; |
|
642 |
|
643 retval = fi.dir_name + file_ops::dir_sep_str + fcn; |
|
644 |
|
645 if (type == load_path::OCT_FILE) |
|
646 { |
|
647 if ((type & t) == load_path::OCT_FILE) |
|
648 { |
|
649 retval += ".oct"; |
|
650 break; |
|
651 } |
|
652 } |
|
653 else if (type == load_path::M_FILE) |
|
654 { |
|
655 if ((type & t) == load_path::M_FILE) |
|
656 { |
|
657 retval += ".m"; |
|
658 break; |
|
659 } |
|
660 } |
5864
|
661 else if (type == load_path::MEX_FILE) |
|
662 { |
|
663 if ((type & t) == load_path::MEX_FILE) |
|
664 { |
|
665 retval += ".mex"; |
|
666 break; |
|
667 } |
|
668 } |
5832
|
669 else if (type == (load_path::M_FILE | load_path::OCT_FILE)) |
|
670 { |
|
671 if (t & load_path::OCT_FILE) |
|
672 { |
|
673 retval += ".oct"; |
|
674 break; |
|
675 } |
|
676 else if (t & load_path::M_FILE) |
|
677 { |
|
678 retval += ".m"; |
|
679 break; |
|
680 } |
|
681 } |
5864
|
682 else if (type == (load_path::M_FILE | load_path::MEX_FILE)) |
|
683 { |
|
684 if (t & load_path::MEX_FILE) |
|
685 { |
|
686 retval += ".mex"; |
|
687 break; |
|
688 } |
|
689 else if (t & load_path::M_FILE) |
|
690 { |
|
691 retval += ".m"; |
|
692 break; |
|
693 } |
|
694 } |
|
695 else if (type == (load_path::OCT_FILE | load_path::MEX_FILE)) |
|
696 { |
|
697 if (t & load_path::OCT_FILE) |
|
698 { |
|
699 retval += ".oct"; |
|
700 break; |
|
701 } |
|
702 else if (t & load_path::MEX_FILE) |
|
703 { |
|
704 retval += ".mex"; |
|
705 break; |
|
706 } |
|
707 } |
|
708 else if (type == (load_path::M_FILE | load_path::OCT_FILE |
|
709 | load_path::MEX_FILE)) |
|
710 { |
|
711 if (t & load_path::OCT_FILE) |
|
712 { |
|
713 retval += ".oct"; |
|
714 break; |
|
715 } |
|
716 else if (t & load_path::MEX_FILE) |
|
717 { |
|
718 retval += ".mex"; |
|
719 break; |
|
720 } |
|
721 else if (t & load_path::M_FILE) |
|
722 { |
|
723 retval += ".m"; |
|
724 break; |
|
725 } |
|
726 } |
5832
|
727 else |
|
728 error ("load_path::do_find_fcn: %s: invalid type code = %d", |
|
729 fcn.c_str (), type); |
|
730 } |
|
731 } |
|
732 |
|
733 return retval; |
|
734 } |
|
735 |
|
736 std::string |
|
737 load_path::do_find_file (const std::string& file) const |
|
738 { |
|
739 std::string retval; |
|
740 |
|
741 if (octave_env::absolute_pathname (file)) |
|
742 { |
|
743 file_stat fs (file); |
|
744 |
|
745 if (fs.exists ()) |
|
746 return file; |
|
747 } |
|
748 |
|
749 std::string dir_name; |
|
750 |
|
751 for (const_dir_info_list_iterator p = dir_info_list.begin (); |
|
752 p != dir_info_list.end (); |
|
753 p++) |
|
754 { |
|
755 string_vector all_files = p->all_files; |
|
756 |
|
757 octave_idx_type len = all_files.length (); |
|
758 |
|
759 for (octave_idx_type i = 0; i < len; i++) |
|
760 { |
|
761 if (all_files[i] == file) |
|
762 { |
|
763 dir_name = p->dir_name; |
|
764 break; |
|
765 } |
|
766 } |
|
767 } |
|
768 |
|
769 if (! dir_name.empty ()) |
|
770 retval = dir_name + file_ops::dir_sep_str + file; |
|
771 |
|
772 return retval; |
|
773 } |
|
774 |
|
775 std::string |
|
776 load_path::do_find_first_of (const string_vector& flist) const |
|
777 { |
|
778 std::string retval; |
|
779 |
|
780 std::string dir_name; |
|
781 std::string file_name; |
|
782 |
|
783 octave_idx_type flen = flist.length (); |
|
784 octave_idx_type rel_flen = 0; |
|
785 |
|
786 string_vector rel_flist (flen); |
|
787 |
|
788 for (octave_idx_type i = 0; i < flen; i++) |
|
789 { |
|
790 if (octave_env::absolute_pathname (flist[i])) |
|
791 { |
|
792 file_stat fs (flist[i]); |
|
793 |
|
794 if (fs.exists ()) |
|
795 return flist[i]; |
|
796 } |
|
797 else |
|
798 rel_flist[rel_flen++] = flist[i]; |
|
799 } |
|
800 |
|
801 rel_flist.resize (rel_flen); |
|
802 |
|
803 for (const_dir_info_list_iterator p = dir_info_list.begin (); |
|
804 p != dir_info_list.end (); |
|
805 p++) |
|
806 { |
|
807 string_vector all_files = p->all_files; |
|
808 |
|
809 octave_idx_type len = all_files.length (); |
|
810 |
|
811 for (octave_idx_type i = 0; i < len; i++) |
|
812 { |
|
813 |
|
814 for (octave_idx_type j = 0; j < rel_flen; j++) |
|
815 { |
|
816 if (all_files[i] == rel_flist[j]) |
|
817 { |
|
818 dir_name = p->dir_name; |
|
819 file_name = rel_flist[j]; |
|
820 break; |
|
821 } |
|
822 } |
|
823 } |
|
824 } |
|
825 |
|
826 if (! dir_name.empty ()) |
|
827 retval = dir_name + file_ops::dir_sep_str + file_name; |
|
828 |
|
829 return retval; |
|
830 } |
|
831 |
|
832 string_vector |
|
833 load_path::do_find_all_first_of (const string_vector& flist) const |
|
834 { |
|
835 std::list<std::string> retlist; |
|
836 |
|
837 std::string dir_name; |
|
838 std::string file_name; |
|
839 |
|
840 octave_idx_type flen = flist.length (); |
|
841 octave_idx_type rel_flen = 0; |
|
842 |
|
843 string_vector rel_flist (flen); |
|
844 |
|
845 for (octave_idx_type i = 0; i < flen; i++) |
|
846 { |
|
847 if (octave_env::absolute_pathname (flist[i])) |
|
848 { |
|
849 file_stat fs (flist[i]); |
|
850 |
|
851 if (fs.exists ()) |
|
852 retlist.push_back (flist[i]); |
|
853 } |
|
854 else |
|
855 rel_flist[rel_flen++] = flist[i]; |
|
856 } |
|
857 |
|
858 rel_flist.resize (rel_flen); |
|
859 |
|
860 for (const_dir_info_list_iterator p = dir_info_list.begin (); |
|
861 p != dir_info_list.end (); |
|
862 p++) |
|
863 { |
|
864 string_vector all_files = p->all_files; |
|
865 |
|
866 octave_idx_type len = all_files.length (); |
|
867 |
|
868 for (octave_idx_type i = 0; i < len; i++) |
|
869 { |
|
870 for (octave_idx_type j = 0; j < rel_flen; j++) |
|
871 { |
|
872 if (all_files[i] == rel_flist[j]) |
|
873 retlist.push_back |
|
874 (p->dir_name + file_ops::dir_sep_str + rel_flist[j]); |
|
875 } |
|
876 } |
|
877 } |
|
878 |
|
879 size_t retsize = retlist.size (); |
|
880 |
|
881 string_vector retval (retsize); |
|
882 |
|
883 for (size_t i = 0; i < retsize; i++) |
|
884 { |
|
885 retval[i] = retlist.front (); |
|
886 |
|
887 retlist.pop_front (); |
|
888 } |
|
889 |
|
890 return retval; |
|
891 } |
|
892 |
|
893 string_vector |
|
894 load_path::do_dirs (void) const |
|
895 { |
|
896 size_t len = dir_info_list.size (); |
|
897 |
|
898 string_vector retval (len); |
|
899 |
|
900 octave_idx_type k = 0; |
|
901 |
|
902 for (const_dir_info_list_iterator i = dir_info_list.begin (); |
|
903 i != dir_info_list.end (); |
|
904 i++) |
|
905 retval[k++] = i->dir_name; |
|
906 |
|
907 return retval; |
|
908 } |
|
909 |
|
910 std::list<std::string> |
|
911 load_path::do_dir_list (void) const |
|
912 { |
|
913 std::list<std::string> retval; |
|
914 |
|
915 for (const_dir_info_list_iterator i = dir_info_list.begin (); |
|
916 i != dir_info_list.end (); |
|
917 i++) |
|
918 retval.push_back (i->dir_name); |
|
919 |
|
920 return retval; |
|
921 } |
|
922 |
|
923 string_vector |
|
924 load_path::do_files (const std::string& dir) const |
|
925 { |
|
926 string_vector retval; |
|
927 |
|
928 const_dir_info_list_iterator i = find_dir_info (dir); |
|
929 |
|
930 if (i != dir_info_list.end ()) |
|
931 retval = i->fcn_files; |
|
932 |
|
933 return retval; |
|
934 } |
|
935 |
|
936 string_vector |
|
937 load_path::do_fcn_names (void) const |
|
938 { |
|
939 size_t len = fcn_map.size (); |
|
940 |
|
941 string_vector retval (len); |
|
942 |
|
943 octave_idx_type count = 0; |
|
944 |
|
945 for (const_fcn_map_iterator p = fcn_map.begin (); |
|
946 p != fcn_map.end (); |
|
947 p++) |
|
948 retval[count++] = p->first; |
|
949 |
|
950 return retval; |
|
951 } |
|
952 |
|
953 std::string |
|
954 load_path::do_path (void) const |
|
955 { |
|
956 std::string xpath; |
|
957 |
|
958 string_vector xdirs = load_path::dirs (); |
|
959 |
|
960 octave_idx_type len = xdirs.length (); |
|
961 |
|
962 if (len > 0) |
|
963 xpath = xdirs[0]; |
|
964 |
|
965 for (octave_idx_type i = 1; i < len; i++) |
|
966 xpath += dir_path::path_sep_str + xdirs[i]; |
|
967 |
|
968 return xpath; |
|
969 } |
|
970 |
|
971 void |
|
972 load_path::do_display (std::ostream& os) const |
|
973 { |
|
974 for (const_dir_info_list_iterator i = dir_info_list.begin (); |
|
975 i != dir_info_list.end (); |
|
976 i++) |
|
977 { |
|
978 string_vector fcn_files = i->fcn_files; |
|
979 |
|
980 if (! fcn_files.empty ()) |
|
981 { |
|
982 os << "\n*** function files in " << i->dir_name << ":\n\n"; |
|
983 |
|
984 fcn_files.list_in_columns (os); |
|
985 } |
|
986 |
|
987 #if defined (DEBUG_LOAD_PATH) |
|
988 |
|
989 const std::map<std::string, int>& private_function_map |
|
990 = i->private_function_map; |
|
991 |
|
992 if (private_function_map.size () > 0) |
|
993 { |
|
994 os << "private:\n"; |
|
995 |
|
996 for (std::map<std::string, int>::const_iterator p = private_function_map.begin (); |
|
997 p != private_function_map.end (); |
|
998 p++) |
|
999 { |
|
1000 os << " " << p->first << " ("; |
|
1001 |
|
1002 bool printed_type = false; |
|
1003 |
|
1004 int types = p->second; |
|
1005 |
|
1006 if (types & load_path::OCT_FILE) |
|
1007 { |
|
1008 os << "oct"; |
|
1009 printed_type = true; |
|
1010 } |
|
1011 |
5864
|
1012 if (types & load_path::MEX_FILE) |
|
1013 { |
|
1014 if (printed_type) |
|
1015 os << "|"; |
|
1016 os << "mex"; |
|
1017 printed_type = true; |
|
1018 } |
|
1019 |
5832
|
1020 if (types & load_path::M_FILE) |
|
1021 { |
|
1022 if (printed_type) |
|
1023 os << "|"; |
|
1024 os << "m"; |
|
1025 printed_type = true; |
|
1026 } |
|
1027 |
|
1028 os << ")\n"; |
|
1029 } |
|
1030 |
|
1031 os << "\n"; |
|
1032 } |
|
1033 #endif |
|
1034 } |
|
1035 |
|
1036 #if defined (DEBUG_LOAD_PATH) |
|
1037 |
|
1038 for (const_fcn_map_iterator i = fcn_map.begin (); |
|
1039 i != fcn_map.end (); |
|
1040 i++) |
|
1041 { |
|
1042 os << i->first << ":\n"; |
|
1043 |
|
1044 const std::list<file_info>& file_info_list = i->second; |
|
1045 |
|
1046 for (const_file_info_list_iterator p = file_info_list.begin (); |
|
1047 p != file_info_list.end (); |
|
1048 p++) |
|
1049 { |
|
1050 os << " " << p->dir_name << " ("; |
|
1051 |
|
1052 bool printed_type = false; |
|
1053 |
|
1054 if (p->types & load_path::OCT_FILE) |
|
1055 { |
|
1056 os << "oct"; |
|
1057 printed_type = true; |
|
1058 } |
|
1059 |
5864
|
1060 if (p->types & load_path::MEX_FILE) |
|
1061 { |
|
1062 if (printed_type) |
|
1063 os << "|"; |
|
1064 os << "mex"; |
|
1065 printed_type = true; |
|
1066 } |
|
1067 |
5832
|
1068 if (p->types & load_path::M_FILE) |
|
1069 { |
|
1070 if (printed_type) |
|
1071 os << "|"; |
|
1072 os << "m"; |
|
1073 printed_type = true; |
|
1074 } |
|
1075 |
|
1076 os << ")\n"; |
|
1077 } |
|
1078 } |
|
1079 |
|
1080 os << "\n"; |
|
1081 |
|
1082 #endif |
|
1083 } |
|
1084 |
|
1085 void |
|
1086 load_path::add_to_fcn_map (const dir_info& di, bool at_end) const |
|
1087 { |
|
1088 std::string dir_name = di.dir_name; |
|
1089 |
|
1090 string_vector fcn_files = di.fcn_files; |
|
1091 |
|
1092 octave_idx_type len = fcn_files.length (); |
|
1093 |
|
1094 for (octave_idx_type i = 0; i < len; i++) |
|
1095 { |
|
1096 std::string fname = fcn_files[i]; |
|
1097 |
|
1098 std::string ext; |
|
1099 std::string base = fname; |
|
1100 |
|
1101 size_t pos = fname.rfind ('.'); |
|
1102 |
|
1103 if (pos != NPOS) |
|
1104 { |
|
1105 base = fname.substr (0, pos); |
|
1106 ext = fname.substr (pos); |
|
1107 } |
|
1108 |
|
1109 std::list<file_info>& file_info_list = fcn_map[base]; |
|
1110 |
|
1111 file_info_list_iterator p = file_info_list.begin (); |
|
1112 |
|
1113 while (p != file_info_list.end ()) |
|
1114 { |
|
1115 if (p->dir_name == dir_name) |
|
1116 break; |
|
1117 |
|
1118 p++; |
|
1119 } |
|
1120 |
|
1121 int t = 0; |
|
1122 if (ext == ".m") |
|
1123 t = load_path::M_FILE; |
|
1124 else if (ext == ".oct") |
|
1125 t = load_path::OCT_FILE; |
5864
|
1126 else if (ext == ".mex") |
|
1127 t = load_path::MEX_FILE; |
5832
|
1128 |
|
1129 if (p == file_info_list.end ()) |
|
1130 { |
|
1131 file_info fi (dir_name, t); |
|
1132 |
|
1133 if (at_end) |
|
1134 file_info_list.push_back (fi); |
|
1135 else |
|
1136 file_info_list.push_front (fi); |
|
1137 } |
|
1138 else |
|
1139 { |
|
1140 file_info& fi = *p; |
|
1141 |
|
1142 fi.types |= t; |
|
1143 } |
|
1144 } |
|
1145 } |
|
1146 |
|
1147 std::string |
|
1148 genpath (const std::string& dirname, const string_vector& skip) |
|
1149 { |
|
1150 std::string retval; |
|
1151 |
5871
|
1152 dir_entry dir (dirname); |
5832
|
1153 |
|
1154 if (dir) |
|
1155 { |
|
1156 retval = dirname; |
|
1157 |
|
1158 string_vector dirlist = dir.read (); |
|
1159 |
|
1160 octave_idx_type len = dirlist.length (); |
|
1161 |
|
1162 for (octave_idx_type i = 0; i < len; i++) |
|
1163 { |
|
1164 std::string elt = dirlist[i]; |
|
1165 |
|
1166 // FIXME -- the caller should be able to specify the list of |
|
1167 // directories to skip in addition to "." and "..". |
|
1168 |
|
1169 bool skip_p = (elt == "." || elt == ".."); |
|
1170 |
|
1171 if (! skip_p) |
|
1172 { |
|
1173 for (octave_idx_type j = 0; j < skip.length (); j++) |
|
1174 { |
|
1175 skip_p = (elt == skip[j]); |
|
1176 if (skip_p) |
|
1177 break; |
|
1178 } |
|
1179 |
|
1180 if (! skip_p) |
|
1181 { |
5871
|
1182 std::string nm = dirname + file_ops::dir_sep_str + elt; |
5832
|
1183 |
|
1184 file_stat fs (nm); |
|
1185 |
|
1186 if (fs && fs.is_dir ()) |
|
1187 retval += dir_path::path_sep_str + genpath (nm); |
|
1188 } |
|
1189 } |
|
1190 } |
|
1191 } |
|
1192 |
|
1193 return retval; |
|
1194 } |
|
1195 |
|
1196 static void |
|
1197 execute_pkg_add_or_del (const std::string& dir, |
|
1198 const std::string& script_file) |
|
1199 { |
|
1200 if (! octave_interpreter_ready) |
|
1201 return; |
|
1202 |
|
1203 unwind_protect::begin_frame ("execute_pkg_add_or_del"); |
|
1204 |
|
1205 unwind_protect_bool (input_from_startup_file); |
|
1206 |
|
1207 input_from_startup_file = true; |
|
1208 |
|
1209 std::string file = dir + file_ops::dir_sep_str + script_file; |
|
1210 |
|
1211 file_stat fs = file_stat (file); |
|
1212 |
|
1213 if (fs.exists ()) |
|
1214 source_file (file); |
|
1215 |
|
1216 unwind_protect::run_frame ("execute_pkg_add_or_del"); |
|
1217 } |
|
1218 |
|
1219 void |
|
1220 execute_pkg_add (const std::string& dir) |
|
1221 { |
|
1222 execute_pkg_add_or_del (dir, "PKG_ADD"); |
|
1223 } |
|
1224 |
|
1225 void |
|
1226 execute_pkg_del (const std::string& dir) |
|
1227 { |
|
1228 execute_pkg_add_or_del (dir, "PKG_DEL"); |
|
1229 } |
|
1230 |
|
1231 DEFUN (genpath, args, , |
|
1232 "-*- texinfo -*-\n\ |
|
1233 @deftypefn {Built-in Function} {} genpath (@var{dir})\n\ |
|
1234 Return a path constructed from @var{dir} and all its subdiretories.\n\ |
|
1235 @end deftypefn") |
|
1236 { |
|
1237 octave_value retval; |
|
1238 |
|
1239 if (args.length () == 1) |
|
1240 { |
|
1241 std::string dirname = args(0).string_value (); |
|
1242 |
|
1243 if (! error_state) |
|
1244 retval = genpath (dirname); |
|
1245 else |
|
1246 error ("genpath: expecting argument to be a character string"); |
|
1247 } |
|
1248 else |
|
1249 print_usage (); |
|
1250 |
|
1251 return retval; |
|
1252 } |
|
1253 |
|
1254 DEFUN (rehash, , , |
|
1255 "-*- texinfo -*-\n\ |
|
1256 @deftypefn {Built-in Function} {} rehash ()\n\ |
|
1257 Reinitialize Octave's @code{LOADPATH} directory cache.\n\ |
|
1258 @end deftypefn") |
|
1259 { |
|
1260 octave_value_list retval; |
|
1261 |
|
1262 load_path::update (); |
|
1263 |
|
1264 // FIXME -- maybe we should rename this variable since it is being |
|
1265 // used for more than keeping track of the prompt time. |
|
1266 |
|
1267 // This will force updated functions to be found. |
|
1268 Vlast_prompt_time.stamp (); |
|
1269 |
|
1270 return retval; |
|
1271 } |
|
1272 |
|
1273 DEFUN (pathdef, , , |
|
1274 "-*- texinfo -*-\n\ |
|
1275 @deftypefn {Built-in Function} {@var{val} =} pathdef ()\n\ |
|
1276 Return the default list of directories in which to search for function\n\ |
|
1277 files.\n\ |
|
1278 @seealso{path, addpath, rmpath, genpath, savepath, pathsep}\n\ |
|
1279 @end deftypefn") |
|
1280 { |
|
1281 return octave_value (Vsystem_path); |
|
1282 } |
|
1283 |
|
1284 DEFUN (path, args, nargout, |
|
1285 "-*- texinfo -*-\n\ |
|
1286 @deftypefn {Function File} {} path (@dots{})\n\ |
|
1287 Modify or display Octave's @code{LOADPATH}.\n\ |
|
1288 \n\ |
|
1289 If @var{nargin} and @var{nargout} are zero, display the elements of\n\ |
|
1290 Octave's @code{LOADPATH} in an easy to read format.\n\ |
|
1291 \n\ |
|
1292 If @var{nargin} is zero and nargout is greater than zero, return the\n\ |
|
1293 current value of @code{LOADPATH}.\n\ |
|
1294 \n\ |
|
1295 If @var{nargin} is greater than zero, concatenate the arguments,\n\ |
|
1296 separating them with @code{pathsep()}. Set the internal search path\n\ |
|
1297 to the result and return it.\n\ |
|
1298 \n\ |
|
1299 No checks are made for duplicate elements.\n\ |
|
1300 @seealso{addpath, rmpath, genpath, pathdef, savepath, pathsep}\n\ |
|
1301 @end deftypefn") |
|
1302 { |
|
1303 octave_value retval; |
|
1304 |
|
1305 int argc = args.length () + 1; |
|
1306 |
|
1307 string_vector argv = args.make_argv ("path"); |
|
1308 |
|
1309 if (! error_state) |
|
1310 { |
|
1311 if (argc > 1) |
|
1312 { |
|
1313 std::string path = argv[1]; |
|
1314 |
|
1315 for (int i = 2; i < argc; i++) |
5867
|
1316 path += dir_path::path_sep_str + argv[i]; |
5832
|
1317 |
5867
|
1318 load_path::set (path, true); |
5832
|
1319 } |
|
1320 |
|
1321 if (nargout > 0) |
|
1322 retval = load_path::path (); |
|
1323 else if (argc == 1 && nargout == 0) |
|
1324 { |
|
1325 octave_stdout << "\nOctave's search path contains the following directories:\n\n"; |
|
1326 |
|
1327 string_vector dirs = load_path::dirs (); |
|
1328 |
|
1329 dirs.list_in_columns (octave_stdout); |
|
1330 |
|
1331 octave_stdout << "\n"; |
|
1332 } |
|
1333 } |
|
1334 |
|
1335 return retval; |
|
1336 } |
|
1337 |
|
1338 DEFCMD (addpath, args, nargout, |
|
1339 "-*- texinfo -*-\n\ |
|
1340 @deftypefn {Function File} {} addpath (@var{dir1}, @dots{})\n\ |
|
1341 @deftypefnx {Function File} {} addpath (@var{dir1}, @dots{}, @var{option})\n\ |
|
1342 Add @var{dir1}, @dots{} to the current function search path. If\n\ |
|
1343 @var{option} is @samp{\"-begin\"} or 0 (the default), prepend the\n\ |
|
1344 directory name to the current path. If @var{option} is @samp{\"-end\"}\n\ |
|
1345 or 1, append the directory name to the current path.\n\ |
|
1346 Directories added to the path must exist.\n\ |
|
1347 @seealso{path, rmpath, genpath, pathdef, savepath, pathsep}\n\ |
|
1348 @end deftypefn") |
|
1349 { |
|
1350 octave_value retval; |
|
1351 |
|
1352 // Originally written by Bill Denney and Etienne Grossman. Heavily |
|
1353 // modified and translated to C++ by jwe. |
|
1354 |
|
1355 if (nargout > 0) |
|
1356 retval = load_path::path (); |
|
1357 |
|
1358 int nargin = args.length (); |
|
1359 |
|
1360 if (nargin > 0) |
|
1361 { |
|
1362 bool append = false; |
|
1363 |
|
1364 octave_value option_arg = args(nargin-1); |
|
1365 |
|
1366 if (option_arg.is_string ()) |
|
1367 { |
|
1368 std::string option = option_arg.string_value (); |
|
1369 |
|
1370 if (option == "-end") |
|
1371 { |
|
1372 append = true; |
|
1373 nargin--; |
|
1374 } |
|
1375 else if (option == "-begin") |
|
1376 nargin--; |
|
1377 } |
|
1378 else if (option_arg.is_numeric_type ()) |
|
1379 { |
|
1380 int val = option_arg.int_value (); |
|
1381 |
|
1382 if (! error_state) |
|
1383 { |
|
1384 if (val == 0) |
|
1385 append = false; |
|
1386 else if (val == 1) |
|
1387 append = true; |
|
1388 else |
|
1389 { |
|
1390 error ("addpath: expecting final argument to be 1 or 0"); |
|
1391 return retval; |
|
1392 } |
|
1393 } |
|
1394 else |
|
1395 { |
|
1396 error ("addpath: expecting final argument to be 1 or 0"); |
|
1397 return retval; |
|
1398 } |
|
1399 } |
|
1400 |
|
1401 for (int i = 0; i < nargin; i++) |
|
1402 { |
|
1403 std::string arg = args(i).string_value (); |
|
1404 |
|
1405 if (! error_state) |
|
1406 { |
|
1407 std::list<std::string> dir_elts = split_path (arg); |
|
1408 |
|
1409 for (std::list<std::string>::const_iterator p = dir_elts.begin (); |
|
1410 p != dir_elts.end (); |
|
1411 p++) |
|
1412 { |
|
1413 std::string dir = *p; |
|
1414 |
|
1415 //dir = regexprep (dir_elts{j}, "//+", "/"); |
|
1416 //dir = regexprep (dir, "/$", ""); |
|
1417 |
5867
|
1418 if (append) |
|
1419 load_path::append (dir, true); |
5832
|
1420 else |
5867
|
1421 load_path::prepend (dir, true); |
5832
|
1422 } |
|
1423 } |
|
1424 else |
|
1425 error ("addpath: expecting all args to be character strings"); |
|
1426 } |
|
1427 } |
|
1428 else |
|
1429 print_usage (); |
|
1430 |
|
1431 return retval; |
|
1432 } |
|
1433 |
|
1434 DEFCMD (rmpath, args, nargout, |
|
1435 "-*- texinfo -*-\n\ |
|
1436 @deftypefn {Function File} {} rmpath (@var{dir1}, @dots{})\n\ |
|
1437 Remove @var{dir1}, @dots{} from the current function search path.\n\ |
|
1438 \n\ |
|
1439 @seealso{path, addpath, genpath, pathdef, savepath, pathsep}\n\ |
|
1440 @end deftypefn") |
|
1441 { |
|
1442 // Originally by Etienne Grossmann. Heavily modified and translated |
|
1443 // to C++ by jwe. |
|
1444 |
|
1445 octave_value retval; |
|
1446 |
|
1447 if (nargout > 0) |
|
1448 retval = load_path::path (); |
|
1449 |
|
1450 int nargin = args.length (); |
|
1451 |
|
1452 if (nargin > 0) |
|
1453 { |
|
1454 for (int i = 0; i < nargin; i++) |
|
1455 { |
|
1456 std::string arg = args(i).string_value (); |
|
1457 |
|
1458 if (! error_state) |
|
1459 { |
|
1460 std::list<std::string> dir_elts = split_path (arg); |
|
1461 |
|
1462 for (std::list<std::string>::const_iterator p = dir_elts.begin (); |
|
1463 p != dir_elts.end (); |
|
1464 p++) |
|
1465 { |
|
1466 std::string dir = *p; |
|
1467 |
|
1468 //dir = regexprep (dir_elts{j}, "//+", "/"); |
|
1469 //dir = regexprep (dir, "/$", ""); |
|
1470 |
|
1471 if (! load_path::remove (dir)) |
|
1472 warning ("rmpath: %s: not found", dir.c_str ()); |
|
1473 } |
|
1474 } |
|
1475 else |
|
1476 error ("addpath: expecting all args to be character strings"); |
|
1477 } |
|
1478 } |
|
1479 else |
|
1480 print_usage (); |
|
1481 |
|
1482 return retval; |
|
1483 } |
|
1484 |
|
1485 /* |
|
1486 ;;; Local Variables: *** |
|
1487 ;;; mode: C++ *** |
|
1488 ;;; End: *** |
|
1489 */ |