Mercurial > octave-nkf
diff src/load-path.cc @ 11105:a6ab46b5926f
load_path::do_find{all,}first_of: search path for relative file names
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 18 Oct 2010 01:19:28 -0400 |
parents | c9b0a75b02e8 |
children | fd0a3ac60b0e |
line wrap: on
line diff
--- a/src/load-path.cc Sun Oct 17 23:43:42 2010 -0400 +++ b/src/load-path.cc Mon Oct 18 01:19:28 2010 -0400 @@ -1257,15 +1257,35 @@ for (octave_idx_type i = 0; i < flen; i++) { - if (octave_env::absolute_pathname (flist[i])) + std::string file = flist[i]; + + if (file.find_first_of (file_ops::dir_sep_chars ()) != std::string::npos) { - file_stat fs (flist[i]); - - if (fs.exists ()) - return flist[i]; + if (octave_env::absolute_pathname (file) + || octave_env::rooted_relative_pathname (file)) + { + file_stat fs (file); + + if (fs.exists ()) + return file; + } + else + { + for (const_dir_info_list_iterator p = dir_info_list.begin (); + p != dir_info_list.end (); + p++) + { + std::string tfile = file_ops::concat (p->dir_name, file); + + file_stat fs (tfile); + + if (fs.exists ()) + return tfile; + } + } } else - rel_flist[rel_flen++] = flist[i]; + rel_flist[rel_flen++] = file; } rel_flist.resize (rel_flen); @@ -1316,15 +1336,35 @@ for (octave_idx_type i = 0; i < flen; i++) { - if (octave_env::absolute_pathname (flist[i])) + std::string file = flist[i]; + + if (file.find_first_of (file_ops::dir_sep_chars ()) != std::string::npos) { - file_stat fs (flist[i]); - - if (fs.exists ()) - retlist.push_back (flist[i]); + if (octave_env::absolute_pathname (file) + || octave_env::rooted_relative_pathname (file)) + { + file_stat fs (file); + + if (fs.exists ()) + retlist.push_back (file); + } + else + { + for (const_dir_info_list_iterator p = dir_info_list.begin (); + p != dir_info_list.end (); + p++) + { + std::string tfile = file_ops::concat (p->dir_name, file); + + file_stat fs (tfile); + + if (fs.exists ()) + retlist.push_back (tfile); + } + } } else - rel_flist[rel_flen++] = flist[i]; + rel_flist[rel_flen++] = file; } rel_flist.resize (rel_flen);