diff --git a/libinterp/corefcn/debug.cc b/libinterp/corefcn/debug.cc --- a/libinterp/corefcn/debug.cc +++ b/libinterp/corefcn/debug.cc @@ -594,7 +594,9 @@ do_dbtype (std::ostream& os, const std:: os << "dbtype: unknown function " << name << "\n"; else { - std::ifstream fs (octave::sys::get_ASCII_filename (ff).c_str (), std::ios::in); + std::string ascii_fname = octave::sys::get_ASCII_filename (ff); + + std::ifstream fs (ascii_fname.c_str (), std::ios::in); if (! fs) os << "dbtype: unable to open '" << ff << "' for reading!\n"; diff --git a/libinterp/corefcn/dlmread.cc b/libinterp/corefcn/dlmread.cc --- a/libinterp/corefcn/dlmread.cc +++ b/libinterp/corefcn/dlmread.cc @@ -221,7 +221,9 @@ such as text, are also replaced by the @ tname = find_data_file_in_load_path ("dlmread", tname); - input_file.open (octave::sys::get_ASCII_filename (tname).c_str (), std::ios::in); + std::string ascii_fname = octave::sys::get_ASCII_filename (tname); + + input_file.open (ascii_fname.c_str (), std::ios::in); if (! input_file) error ("dlmread: unable to open file '%s'", fname.c_str ()); diff --git a/libinterp/corefcn/help.cc b/libinterp/corefcn/help.cc --- a/libinterp/corefcn/help.cc +++ b/libinterp/corefcn/help.cc @@ -582,9 +582,11 @@ namespace octave if (! initialized) { - std::ifstream file ( - octave::sys::get_ASCII_filename (m_built_in_docstrings_file).c_str (), - std::ios::in | std::ios::binary); + std::string ascii_fname + = octave::sys::get_ASCII_filename (m_built_in_docstrings_file); + + std::ifstream file (ascii_fname.c_str (), + std::ios::in | std::ios::binary); if (! file) error ("failed to open docstrings file: %s", @@ -666,9 +668,11 @@ namespace octave std::streampos beg = txt_limits.first; std::streamoff len = txt_limits.second; - std::ifstream file ( - octave::sys::get_ASCII_filename (m_built_in_docstrings_file).c_str (), - std::ios::in | std::ios::binary); + std::string ascii_fname + = octave::sys::get_ASCII_filename (m_built_in_docstrings_file); + + std::ifstream file (ascii_fname.c_str (), + std::ios::in | std::ios::binary); if (! file) error ("failed to open docstrings file: %s", diff --git a/libinterp/corefcn/load-save.cc b/libinterp/corefcn/load-save.cc --- a/libinterp/corefcn/load-save.cc +++ b/libinterp/corefcn/load-save.cc @@ -226,7 +226,9 @@ check_gzip_magic (const std::string& fna { bool retval = false; - std::ifstream file (octave::sys::get_ASCII_filename (fname).c_str (), + std::string ascii_fname = octave::sys::get_ASCII_filename (fname); + + std::ifstream file (ascii_fname.c_str (), std::ios::in | std::ios::binary); unsigned char magic[2]; @@ -313,21 +315,23 @@ get_file_format (const std::string& fnam { load_save_format retval = LS_UNKNOWN; + std::string ascii_fname = octave::sys::get_ASCII_filename (fname); + #if defined (HAVE_HDF5) // check this before we open the file - if (H5Fis_hdf5 (octave::sys::get_ASCII_filename (fname).c_str ()) > 0) + if (H5Fis_hdf5 (ascii_fname.c_str ()) > 0) return LS_HDF5; #endif #if defined (HAVE_ZLIB) - use_zlib = check_gzip_magic (fname); + use_zlib = check_gzip_magic (ascii_fname); #else use_zlib = false; #endif if (! use_zlib) { - std::ifstream file (octave::sys::get_ASCII_filename (fname).c_str (), + std::ifstream file (ascii_fname.c_str (), std::ios::in | std::ios::binary); if (file) { @@ -836,8 +840,9 @@ Force Octave to assume the file is in Oc else #endif { - std::ifstream file ( - octave::sys::get_ASCII_filename (fname).c_str (), mode); + std::string ascii_fname = octave::sys::get_ASCII_filename (fname); + + std::ifstream file (ascii_fname.c_str (), mode); if (! file) error ("load: unable to open input file '%s'", @@ -1700,9 +1705,10 @@ file @file{data} in Octave's binary form if (append) error ("save: appending to HDF5 files is not implemented"); + std::string ascii_fname = octave::sys::get_ASCII_filename (fname); + bool write_header_info - = ! (append && H5Fis_hdf5 ( - octave::sys::get_ASCII_filename (fname).c_str ()) > 0); + = ! (append && H5Fis_hdf5 (ascii_fname.c_str ()) > 0); hdf5_ofstream hdf5_file (fname.c_str (), mode); diff --git a/libinterp/corefcn/ls-hdf5.cc b/libinterp/corefcn/ls-hdf5.cc --- a/libinterp/corefcn/ls-hdf5.cc +++ b/libinterp/corefcn/ls-hdf5.cc @@ -89,8 +89,11 @@ hdf5_fstreambase::hdf5_fstreambase (cons { #if defined (HAVE_HDF5) - const char *s_name = - octave::sys::get_ASCII_filename (std::string (name)).c_str (); + std::string fname (name); + + std::string ascii_fname = octave::sys::get_ASCII_filename (fname); + + const char *s_name = ascii_fname.c_str (); if (mode & std::ios::in) file_id = H5Fopen (s_name, H5F_ACC_RDONLY, octave_H5P_DEFAULT); @@ -102,7 +105,7 @@ hdf5_fstreambase::hdf5_fstreambase (cons // FIXME: For Windows, create a file with an ASCII name in an // accessible folder, close the file move and rename using // wide character API and re-open. - file_id = H5Fcreate (name, H5F_ACC_TRUNC, octave_H5P_DEFAULT, + file_id = H5Fcreate (s_name, H5F_ACC_TRUNC, octave_H5P_DEFAULT, octave_H5P_DEFAULT); } if (file_id < 0) @@ -142,7 +145,11 @@ hdf5_fstreambase::open (const char *name clear (); - const char *s_name = octave::sys::get_ASCII_filename (std::string (name)).c_str (); + std::string fname (name); + + std::string ascii_fname = octave::sys::get_ASCII_filename (fname); + + const char *s_name = ascii_fname.c_str (); if (mode & std::ios::in) file_id = H5Fopen (s_name, H5F_ACC_RDONLY, octave_H5P_DEFAULT); @@ -154,7 +161,8 @@ hdf5_fstreambase::open (const char *name // FIXME: For Windows, create a file with an ASCII name in an // accessible folder, close the file move and rename using // wide character API and re-open. - file_id = H5Fcreate (name, H5F_ACC_TRUNC, octave_H5P_DEFAULT, + + file_id = H5Fcreate (s_name, H5F_ACC_TRUNC, octave_H5P_DEFAULT, octave_H5P_DEFAULT); } if (file_id < 0) diff --git a/libinterp/corefcn/urlwrite.cc b/libinterp/corefcn/urlwrite.cc --- a/libinterp/corefcn/urlwrite.cc +++ b/libinterp/corefcn/urlwrite.cc @@ -637,8 +637,10 @@ Undocumented internal function } else { + std::string ascii_fname = octave::sys::get_ASCII_filename (file); + // FIXME: Does ascii mode need to be flagged here? - std::ifstream ifile (octave::sys::get_ASCII_filename (file).c_str (), + std::ifstream ifile (ascii_fname.c_str (), std::ios::in | std::ios::binary); if (! ifile.is_open ()) diff --git a/libinterp/octave-value/ov-java.cc b/libinterp/octave-value/ov-java.cc --- a/libinterp/octave-value/ov-java.cc +++ b/libinterp/octave-value/ov-java.cc @@ -238,7 +238,9 @@ namespace octave void read_java_opts (const std::string& filename) { - std::ifstream js (octave::sys::get_ASCII_filename (filename).c_str ()); + std::string ascii_fname = octave::sys::get_ASCII_filename (filename); + + std::ifstream js (ascii_fname.c_str ()); if (! js.bad () && ! js.fail ()) { @@ -359,7 +361,9 @@ read_classpath_txt (const std::string& f { std::string classpath; - std::ifstream fs (octave::sys::get_ASCII_filename (filepath).c_str ()); + std::string ascii_fname = octave::sys::get_ASCII_filename (filepath); + + std::ifstream fs (ascii_fname.c_str ()); if (! fs.bad () && ! fs.fail ()) { diff --git a/liboctave/util/file-info.cc b/liboctave/util/file-info.cc --- a/liboctave/util/file-info.cc +++ b/liboctave/util/file-info.cc @@ -81,8 +81,9 @@ namespace octave size_t sz = fs.size (); - std::ifstream file (octave::sys::get_ASCII_filename (fname).c_str (), - std::ios::in | std::ios::binary); + std::string ascii_fname = octave::sys::get_ASCII_filename (fname); + + std::ifstream file (ascii_fname.c_str (), std::ios::in | std::ios::binary); if (file) { diff --git a/liboctave/util/url-transfer.cc b/liboctave/util/url-transfer.cc --- a/liboctave/util/url-transfer.cc +++ b/liboctave/util/url-transfer.cc @@ -202,9 +202,11 @@ namespace octave else { // FIXME: Does ascii mode need to be flagged here? - std::ifstream ifile ( - octave::sys::get_ASCII_filename (realfile).c_str (), - std::ios::in | std::ios::binary); + std::string ascii_fname + = octave::sys::get_ASCII_filename (realfile); + + std::ifstream ifile (ascii_fname.c_str (), + std::ios::in | std::ios::binary); if (! ifile.is_open ()) {