Use glib to open our 'announcements' file, rather than opening directly with ofstream
authorJohn Emmas <johne53@tiscali.co.uk>
Tue, 8 Sep 2015 14:38:17 +0000 (15:38 +0100)
committerJohn Emmas <johne53@tiscali.co.uk>
Tue, 8 Sep 2015 14:45:33 +0000 (15:45 +0100)
(on Windows, std::ofstream doesn't support UTF8)

gtk2_ardour/ardour_ui.cc
gtk2_ardour/pingback.cc

index f2d0132b48580336772d69250debf6a927c39247..ce95aec7e682a67d51b88e332d74424f63051311 100644 (file)
@@ -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);
index 3c46a0c8ff51bb360c0add5d4fd45a1a438c0262..10c798e104c341659c0f339cbd12df8fb952f2fb 100644 (file)
@@ -32,6 +32,7 @@
 
 #include <curl/curl.h>
 
+#include <glib/gstdio.h>
 #include <glibmm/miscutils.h>
 
 #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 {