From d0fdcf2848f9196404f9a8e7e4f16a3cb931e4a2 Mon Sep 17 00:00:00 2001 From: John Emmas Date: Tue, 8 Sep 2015 15:38:17 +0100 Subject: [PATCH] Use glib to open our 'announcements' file, rather than opening directly with ofstream (on Windows, std::ofstream doesn't support UTF8) --- gtk2_ardour/ardour_ui.cc | 21 ++++++++++++++------- gtk2_ardour/pingback.cc | 19 ++++++++++++++----- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index f2d0132b48..ce95aec7e6 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -808,13 +808,20 @@ ARDOUR_UI::check_announcements () _annc_filename.append (VERSIONSTRING); std::string path = Glib::build_filename (user_config_directory(), _annc_filename); - std::ifstream announce_file (path.c_str()); - if ( announce_file.fail() ) - _announce_string = ""; - else { - std::stringstream oss; - oss << announce_file.rdbuf(); - _announce_string = oss.str(); + FILE* fin = g_fopen (path.c_str(), "rb"); + + if (fin) { + std::ifstream announce_file (fin); + + if ( announce_file.fail() ) + _announce_string = ""; + else { + std::stringstream oss; + oss << announce_file.rdbuf(); + _announce_string = oss.str(); + } + + fclose (fin); } pingback (VERSIONSTRING, path); diff --git a/gtk2_ardour/pingback.cc b/gtk2_ardour/pingback.cc index 3c46a0c8ff..10c798e104 100644 --- a/gtk2_ardour/pingback.cc +++ b/gtk2_ardour/pingback.cc @@ -32,6 +32,7 @@ #include +#include #include #include "pbd/compose.h" @@ -221,11 +222,19 @@ _pingback (void *arg) //write announcements to local file, even if the //announcement is empty - - std::ofstream annc_file (cm->announce_path.c_str()); - - if (annc_file) { - annc_file << return_str; + + FILE* fout = g_fopen (cm->announce_path.c_str(), "wb"); + + if (fout) { + { + std::ofstream annc_file (fout); + + if (annc_file) { + annc_file << return_str; + } + } + + fclose (fout); } } } else {