Mercurial > octave-nkf
comparison src/load-path.cc @ 5919:ceaf10a4743c
[project @ 2006-08-14 16:42:02 by jwe]
author | jwe |
---|---|
date | Mon, 14 Aug 2006 16:42:03 +0000 |
parents | a65b51ed388c |
children | e64059303a6f |
comparison
equal
deleted
inserted
replaced
5918:84dc6800fcd8 | 5919:ceaf10a4743c |
---|---|
235 | 235 |
236 return retval; | 236 return retval; |
237 } | 237 } |
238 | 238 |
239 load_path::const_dir_info_list_iterator | 239 load_path::const_dir_info_list_iterator |
240 load_path::find_dir_info (const std::string& dir) const | 240 load_path::find_dir_info (const std::string& dir_arg) const |
241 { | 241 { |
242 std::string dir = file_ops::tilde_expand (dir_arg); | |
243 | |
242 const_dir_info_list_iterator retval = dir_info_list.begin (); | 244 const_dir_info_list_iterator retval = dir_info_list.begin (); |
243 | 245 |
244 while (retval != dir_info_list.end ()) | 246 while (retval != dir_info_list.end ()) |
245 { | 247 { |
246 if (retval->dir_name == dir) | 248 if (retval->dir_name == dir) |
251 | 253 |
252 return retval; | 254 return retval; |
253 } | 255 } |
254 | 256 |
255 load_path::dir_info_list_iterator | 257 load_path::dir_info_list_iterator |
256 load_path::find_dir_info (const std::string& dir) | 258 load_path::find_dir_info (const std::string& dir_arg) |
257 { | 259 { |
260 std::string dir = file_ops::tilde_expand (dir_arg); | |
261 | |
258 dir_info_list_iterator retval = dir_info_list.begin (); | 262 dir_info_list_iterator retval = dir_info_list.begin (); |
259 | 263 |
260 while (retval != dir_info_list.end ()) | 264 while (retval != dir_info_list.end ()) |
261 { | 265 { |
262 if (retval->dir_name == dir) | 266 if (retval->dir_name == dir) |
463 if (! dir.empty ()) | 467 if (! dir.empty ()) |
464 do_add (dir, false, warn); | 468 do_add (dir, false, warn); |
465 } | 469 } |
466 | 470 |
467 void | 471 void |
468 load_path::do_add (const std::string& dir, bool at_end, bool warn) | 472 load_path::do_add (const std::string& dir_arg, bool at_end, bool warn) |
469 { | 473 { |
470 size_t len = dir.length (); | 474 size_t len = dir_arg.length (); |
471 | 475 |
472 if (len > 1 && dir.substr (len-2) == "//") | 476 if (len > 1 && dir_arg.substr (len-2) == "//") |
473 warning_with_id ("Octave:recursive-path-search", | 477 warning_with_id ("Octave:recursive-path-search", |
474 "trailing `//' is no longer special in search path elements"); | 478 "trailing `//' is no longer special in search path elements"); |
479 | |
480 std::string dir = file_ops::tilde_expand (dir_arg); | |
475 | 481 |
476 dir_info_list_iterator i = find_dir_info (dir); | 482 dir_info_list_iterator i = find_dir_info (dir); |
477 | 483 |
478 if (i != dir_info_list.end ()) | 484 if (i != dir_info_list.end ()) |
479 move (i, at_end); | 485 move (i, at_end); |
499 if (add_hook) | 505 if (add_hook) |
500 add_hook (dir); | 506 add_hook (dir); |
501 } | 507 } |
502 } | 508 } |
503 else if (warn) | 509 else if (warn) |
504 warning ("addpath: %s: not a directory", dir.c_str ()); | 510 warning ("addpath: %s: not a directory", dir_arg.c_str ()); |
505 } | 511 } |
506 else if (warn) | 512 else if (warn) |
507 { | 513 { |
508 std::string msg = fs.error (); | 514 std::string msg = fs.error (); |
509 warning ("addpath: %s: %s", dir.c_str (), msg.c_str ()); | 515 warning ("addpath: %s: %s", dir_arg.c_str (), msg.c_str ()); |
510 } | 516 } |
511 } | 517 } |
512 | 518 |
513 // FIXME -- is there a better way to do this? | 519 // FIXME -- is there a better way to do this? |
514 | 520 |
519 else | 525 else |
520 panic_impossible (); | 526 panic_impossible (); |
521 } | 527 } |
522 | 528 |
523 bool | 529 bool |
524 load_path::do_remove (const std::string& dir) | 530 load_path::do_remove (const std::string& dir_arg) |
525 { | 531 { |
526 bool retval = false; | 532 bool retval = false; |
527 | 533 |
528 if (! dir.empty ()) | 534 if (! dir_arg.empty ()) |
529 { | 535 { |
530 if (dir == ".") | 536 if (dir_arg == ".") |
531 { | 537 { |
532 warning ("rmpath: can't remove \".\" from path"); | 538 warning ("rmpath: can't remove \".\" from path"); |
533 | 539 |
534 // Avoid additional warnings. | 540 // Avoid additional warnings. |
535 retval = true; | 541 retval = true; |
536 } | 542 } |
537 else | 543 else |
538 { | 544 { |
545 std::string dir = file_ops::tilde_expand (dir_arg); | |
546 | |
539 dir_info_list_iterator i = find_dir_info (dir); | 547 dir_info_list_iterator i = find_dir_info (dir); |
540 | 548 |
541 if (i != dir_info_list.end ()) | 549 if (i != dir_info_list.end ()) |
542 { | 550 { |
543 retval = true; | 551 retval = true; |