Mercurial > octave
diff libinterp/corefcn/load-path.cc @ 31740:00931c611342
make find_private_file a private load_path member function
* load-path.h, load-path.cc (load_path::find_private_file):
Define as private member function instead of file-scope static
fucntion. Access interpreter through load_path member variable
instead of using global __get_interpreter__ function.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sat, 14 Jan 2023 13:03:22 -0500 |
parents | 597f3ee61a48 |
children | e31eae72aecd |
line wrap: on
line diff
--- a/libinterp/corefcn/load-path.cc Sat Jan 14 10:21:33 2023 -0500 +++ b/libinterp/corefcn/load-path.cc Sat Jan 14 13:03:22 2023 -0500 @@ -147,45 +147,6 @@ return dir; } -// Should we cache all files in private directories, or is it OK to just -// look them up each time as needed? - -static std::string -find_private_file (const std::string& fname) -{ - std::string retval; - - // Look in private directory corresponding to current function (if - // any). - - symbol_scope scope = __get_current_scope__ (); - - octave_user_code *curr_code = scope ? scope.user_code () : nullptr; - - if (curr_code) - { - // Even for private functions, dir_name doesn't contain the - // "private" directory component so we append it here in all - // cases. - - std::string dir_name = curr_code->dir_name (); - - if (! dir_name.empty ()) - { - std::string pfname = dir_name + sys::file_ops::dir_sep_str () - + "private" + sys::file_ops::dir_sep_str () - + fname; - - sys::file_stat fs (pfname); - - if (fs.exists () && fs.is_reg ()) - retval = pfname; - } - } - - return retval; -} - // True if a path is contained in a path list separated by path_sep_char static bool @@ -1334,6 +1295,45 @@ return retval; } +// Should we cache all files in private directories, or is it OK to just +// look them up each time as needed? + +std::string +load_path::find_private_file (const std::string& fname) const +{ + std::string retval; + + // Look in private directory corresponding to current function (if + // any). + + symbol_scope scope = m_interpreter.get_current_scope (); + + octave_user_code *curr_code = scope ? scope.user_code () : nullptr; + + if (curr_code) + { + // Even for private functions, dir_name doesn't contain the + // "private" directory component so we append it here in all + // cases. + + std::string dir_name = curr_code->dir_name (); + + if (! dir_name.empty ()) + { + std::string pfname = dir_name + sys::file_ops::dir_sep_str () + + "private" + sys::file_ops::dir_sep_str () + + fname; + + sys::file_stat fs (pfname); + + if (fs.exists () && fs.is_reg ()) + retval = pfname; + } + } + + return retval; +} + load_path::dir_info::fcn_file_map_type get_fcn_files (const std::string& d) {