comparison 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
comparison
equal deleted inserted replaced
28466:597e7cf93cac 28467:159b6a1eb408
25 25
26 #if defined (HAVE_CONFIG_H) 26 #if defined (HAVE_CONFIG_H)
27 # include "config.h" 27 # include "config.h"
28 #endif 28 #endif
29 29
30 #include <string>
31
32 #include "dir-ops.h" 30 #include "dir-ops.h"
33 #include "file-ops.h" 31 #include "file-ops.h"
34 #include "lo-error.h" 32 #include "lo-error.h"
35 #include "lo-sysdep.h" 33 #include "lo-sysdep.h"
36 #include "putenv-wrapper.h" 34 #include "putenv-wrapper.h"
348 #else 346 #else
349 return std::fopen (filename.c_str (), mode.c_str ()); 347 return std::fopen (filename.c_str (), mode.c_str ());
350 #endif 348 #endif
351 } 349 }
352 350
351 std::fstream
352 fstream (const std::string& filename, const std::ios::openmode mode)
353 {
354 #if defined (OCTAVE_USE_WINDOWS_API)
355
356 std::wstring wfilename = u8_to_wstring (filename);
357
358 return std::fstream (wfilename.c_str (), mode);
359
360 #else
361 return std::fstream (filename.c_str (), mode);
362 #endif
363 }
364
365 std::ifstream
366 ifstream (const std::string& filename, const std::ios::openmode mode)
367 {
368 #if defined (OCTAVE_USE_WINDOWS_API)
369
370 std::wstring wfilename = u8_to_wstring (filename);
371
372 return std::ifstream (wfilename.c_str (), mode);
373
374 #else
375 return std::ifstream (filename.c_str (), mode);
376 #endif
377 }
378
379 std::ofstream
380 ofstream (const std::string& filename, const std::ios::openmode mode)
381 {
382 #if defined (OCTAVE_USE_WINDOWS_API)
383
384 std::wstring wfilename = u8_to_wstring (filename);
385
386 return std::ofstream (wfilename.c_str (), mode);
387
388 #else
389 return std::ofstream (filename.c_str (), mode);
390 #endif
391 }
392
353 void 393 void
354 putenv_wrapper (const std::string& name, const std::string& value) 394 putenv_wrapper (const std::string& name, const std::string& value)
355 { 395 {
356 // This function was adapted from xputenv from Karl Berry's kpathsearch 396 // This function was adapted from xputenv from Karl Berry's kpathsearch
357 // library. 397 // library.