Mercurial > octave
comparison libinterp/corefcn/utils.cc @ 32080:e9fdfebc6db0
Avoid using file_stat in libinterp/corefcn (bug #59711).
* dirfnc.cc (F__mkdir__), file-io.cc (do_stream_open), graphics.cc (Fdrawnow),
interpreter.cc (interpreter::execute_startup_files),
load-path.cc (load_path::find_file, load_path::find_dir,
load_path::find_matching_dirs, load_path::find_first_of,
load_path::find_all_first_of, load_path::execute_pkg_add_or_del,
load_path::add, load_path::find_private_file,
load_path::dir_info::get_file_list, load_path::dir_info::get_method_file_map,
genpath), load-save.cc (find_file_to_load),
ls-mat5.cc (read_mat5_binary_element), urlwrite (Furlwrite),
utils.cc (find_data_file_in_load_path, fcn_file_in_path),
__ftp__.cc (F__ftp_mput__), __magick_read__.cc (F__magick_write__): Use
functions "dir_exists" or "file_exists" instead of "file_stat".
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Sat, 06 May 2023 13:08:38 +0200 |
parents | 9918d52ee76a |
children | 3c608abd55f5 |
comparison
equal
deleted
inserted
replaced
32079:b0785d76430a | 32080:e9fdfebc6db0 |
---|---|
37 | 37 |
38 #include "dir-ops.h" | 38 #include "dir-ops.h" |
39 #include "file-ops.h" | 39 #include "file-ops.h" |
40 #include "file-stat.h" | 40 #include "file-stat.h" |
41 #include "lo-mappers.h" | 41 #include "lo-mappers.h" |
42 #include "lo-sysdep.h" | |
42 #include "lo-utils.h" | 43 #include "lo-utils.h" |
43 #include "nanosleep-wrapper.h" | 44 #include "nanosleep-wrapper.h" |
44 #include "oct-cmplx.h" | 45 #include "oct-cmplx.h" |
45 #include "oct-env.h" | 46 #include "oct-env.h" |
46 #include "oct-locbuf.h" | 47 #include "oct-locbuf.h" |
708 || sys::env::rooted_relative_pathname (fname))) | 709 || sys::env::rooted_relative_pathname (fname))) |
709 { | 710 { |
710 // Load path will also search "." first, but we don't want to | 711 // Load path will also search "." first, but we don't want to |
711 // issue a warning if the file is found in the current directory, | 712 // issue a warning if the file is found in the current directory, |
712 // so do an explicit check for that. | 713 // so do an explicit check for that. |
713 sys::file_stat fs (fname); | |
714 | |
715 bool local_file_ok | 714 bool local_file_ok |
716 = fs.exists () && (fs.is_reg () || ! require_regular_file); | 715 = sys::file_exists (fname, ! require_regular_file); |
717 | 716 |
718 if (! local_file_ok) | 717 if (! local_file_ok) |
719 { | 718 { |
720 load_path& lp = __get_load_path__ (); | 719 load_path& lp = __get_load_path__ (); |
721 | 720 |
732 } | 731 } |
733 | 732 |
734 return fname; | 733 return fname; |
735 } | 734 } |
736 | 735 |
737 // See if there is an function file in the path. | 736 // See if there is a function file in the path. |
738 // If so, return the full path to the file. | 737 // If so, return the full path to the file. |
739 | 738 |
740 std::string fcn_file_in_path (const std::string& name) | 739 std::string fcn_file_in_path (const std::string& name) |
741 { | 740 { |
742 std::string retval; | 741 std::string retval; |
745 | 744 |
746 if (len > 0) | 745 if (len > 0) |
747 { | 746 { |
748 if (sys::env::absolute_pathname (name)) | 747 if (sys::env::absolute_pathname (name)) |
749 { | 748 { |
750 sys::file_stat fs (name); | 749 if (sys::file_exists (name, false)) |
751 | |
752 if (fs.exists () && ! fs.is_dir ()) | |
753 retval = name; | 750 retval = name; |
754 } | 751 } |
755 else if (len > 2 && name[len - 2] == '.' && name[len - 1] == 'm') | 752 else if (len > 2 && name[len - 2] == '.' && name[len - 1] == 'm') |
756 { | 753 { |
757 load_path& lp = __get_load_path__ (); | 754 load_path& lp = __get_load_path__ (); |
786 load_path& lp = __get_load_path__ (); | 783 load_path& lp = __get_load_path__ (); |
787 | 784 |
788 std::string tcontents | 785 std::string tcontents |
789 = sys::file_ops::concat (lp.find_dir (dir), "Contents.m"); | 786 = sys::file_ops::concat (lp.find_dir (dir), "Contents.m"); |
790 | 787 |
791 sys::file_stat fs (tcontents); | 788 if (sys::file_exists (tcontents)) |
792 | |
793 if (fs.exists ()) | |
794 retval = sys::env::make_absolute (tcontents); | 789 retval = sys::env::make_absolute (tcontents); |
795 } | 790 } |
796 | 791 |
797 return retval; | 792 return retval; |
798 } | 793 } |