Mercurial > octave-nkf
comparison libinterp/corefcn/utils.cc @ 19064:9ef10e6a5987
make "file found in path" warnings consistent
* gripes.h, gripes.cc (gripe_data_file_in_path): New function.
* utils.h, utils.cc (find_data_file_in_path): New function. Use
gripe_data_file_in_path to warn.
* file-io.cc (do_stream_open): Call find_data_file_in_path to search
path for file.
* load-save.cc (find_file_to_load): Likewise.
* md5sum.cc (Fmd5sum): Likewise.
* octave.cc (maximum_braindamage): Disable new
Octave:data-file-in-path warning ID instead of
Octave:fopen-file-in-path and Octave:load-file-in-path.
* NEWS: Note change.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 19 Aug 2014 06:40:53 -0400 |
parents | 9ac2357f19bc |
children | 4990d5988cf5 |
comparison
equal
deleted
inserted
replaced
19063:8c648c3a2c8f | 19064:9ef10e6a5987 |
---|---|
448 | 448 |
449 if (! suffix.empty ()) | 449 if (! suffix.empty ()) |
450 nm.append (suffix); | 450 nm.append (suffix); |
451 | 451 |
452 return octave_env::make_absolute (load_path::find_file (nm)); | 452 return octave_env::make_absolute (load_path::find_file (nm)); |
453 } | |
454 | |
455 std::string | |
456 find_data_file_in_load_path (const std::string& fcn, | |
457 const std::string& file, | |
458 bool require_regular_file) | |
459 { | |
460 std::string fname = file; | |
461 | |
462 if (! (octave_env::absolute_pathname (fname) | |
463 || octave_env::rooted_relative_pathname (fname))) | |
464 { | |
465 // Load path will also search "." first, but we don't want to | |
466 // issue a warning if the file is found in the current directory, | |
467 // so do an explicit check for that. | |
468 | |
469 file_stat fs (fname); | |
470 | |
471 bool local_file_ok | |
472 = fs.exists () && (fs.is_reg () || ! require_regular_file); | |
473 | |
474 if (! local_file_ok) | |
475 { | |
476 // Not directly found; search load path. | |
477 | |
478 std::string tmp | |
479 = octave_env::make_absolute (load_path::find_file (fname)); | |
480 | |
481 if (! tmp.empty ()) | |
482 { | |
483 gripe_data_file_in_path (fcn, tmp); | |
484 | |
485 fname = tmp; | |
486 } | |
487 } | |
488 } | |
489 | |
490 return fname; | |
453 } | 491 } |
454 | 492 |
455 // See if there is an function file in the path. If so, return the | 493 // See if there is an function file in the path. If so, return the |
456 // full path to the file. | 494 // full path to the file. |
457 | 495 |