Mercurial > octave
diff liboctave/system/lo-sysdep.cc @ 28467:159b6a1eb408
Use wide character overload to open file streams on Windows.
* liboctave/system/lo-sysdep.cc, liboctave/system/lo-sysdep.h (fstream,
ifstream, ofstream): Add "wrapper" functions to open file streams.
* libinterp/corefcn/__fcn__.cc (F__ftp_mput__, F__ftp_mget__),
libinterp/corefcn/debug.cc (do_dbtype),
libinterp/corefcn/help.cc (help_system::raw_help_from_docstrings_file),
libinterp/corefcn/load-save.cc (check_gzip_magic,
load_save_system::get_file_format, load_save_system::dump_octave_core,
load_save_system::load, load_save_system::save),
libinterp/corefcn/oct-hist.cc (mk_tmp_hist_file,
history_system::do_edit_history),
libinterp/corefcn/urlwrite.cc (Furlwrite),
libinterp/octave-value/ov-java.cc (read_java_opts, read_classpath_txt),
libinterp/parse-tree/oct-parse.yy (get_file_line),
liboctave/util/cmd-hist.cc (gnu_history::do_append),
liboctave/util/file-info.cc (file_info::snarf_file),
liboctave/util/url-transfer.cc (base_url_transfer::mget_directory,
base_url_transfer::mput_directory): Use new functions.
* libinterp/corefcn/dlmread.cc (dlmread): Use wide character overload for
std::ifstream::open on Windows.
* src/mkoctfile.in.cc (octave_u8_conv_to_encoding): Dummy function for
cross-compiler.
(main): Use wide character overload of std::ofstream::open on Windows.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Fri, 12 Jun 2020 22:13:04 +0200 |
parents | 45763d59cb4f |
children | a40e3c3e17fa |
line wrap: on
line diff
--- a/liboctave/system/lo-sysdep.cc Fri Jun 12 11:39:35 2020 -0400 +++ b/liboctave/system/lo-sysdep.cc Fri Jun 12 22:13:04 2020 +0200 @@ -27,8 +27,6 @@ # include "config.h" #endif -#include <string> - #include "dir-ops.h" #include "file-ops.h" #include "lo-error.h" @@ -350,6 +348,48 @@ #endif } + std::fstream + fstream (const std::string& filename, const std::ios::openmode mode) + { +#if defined (OCTAVE_USE_WINDOWS_API) + + std::wstring wfilename = u8_to_wstring (filename); + + return std::fstream (wfilename.c_str (), mode); + +#else + return std::fstream (filename.c_str (), mode); +#endif + } + + std::ifstream + ifstream (const std::string& filename, const std::ios::openmode mode) + { +#if defined (OCTAVE_USE_WINDOWS_API) + + std::wstring wfilename = u8_to_wstring (filename); + + return std::ifstream (wfilename.c_str (), mode); + +#else + return std::ifstream (filename.c_str (), mode); +#endif + } + + std::ofstream + ofstream (const std::string& filename, const std::ios::openmode mode) + { +#if defined (OCTAVE_USE_WINDOWS_API) + + std::wstring wfilename = u8_to_wstring (filename); + + return std::ofstream (wfilename.c_str (), mode); + +#else + return std::ofstream (filename.c_str (), mode); +#endif + } + void putenv_wrapper (const std::string& name, const std::string& value) {