summaryrefslogtreecommitdiff
path: root/libs/ardour/recent_sessions.cc
diff options
context:
space:
mode:
authorJohn Emmas <johne53@tiscali.co.uk>2015-09-08 15:43:23 +0100
committerJohn Emmas <johne53@tiscali.co.uk>2015-09-08 15:45:34 +0100
commitdee324cc36787d84612fd636cfceb4d964792db6 (patch)
tree790e5e641ee66f0c5cf7707f577bbe9574562161 /libs/ardour/recent_sessions.cc
parentd0fdcf2848f9196404f9a8e7e4f16a3cb931e4a2 (diff)
Use glib to open our 'recent file' list, rather than opening directly with ifstream / ofstream
(on Windows, ifstream & ofstream don't support UTF8)
Diffstat (limited to 'libs/ardour/recent_sessions.cc')
-rw-r--r--libs/ardour/recent_sessions.cc31
1 files changed, 22 insertions, 9 deletions
diff --git a/libs/ardour/recent_sessions.cc b/libs/ardour/recent_sessions.cc
index 7458c32ff8..b70d017edc 100644
--- a/libs/ardour/recent_sessions.cc
+++ b/libs/ardour/recent_sessions.cc
@@ -20,8 +20,10 @@
#include <cstring>
#include <cerrno>
#include <fstream>
+#include <iostream>
#include <algorithm>
+#include <glib/gstdio.h>
#include <glibmm/miscutils.h>
#include "pbd/error.h"
@@ -47,10 +49,9 @@ int
ARDOUR::read_recent_sessions (RecentSessions& rs)
{
std::string path = Glib::build_filename (user_config_directory(), recent_file_name);
+ FILE* fin = g_fopen (path.c_str(), "rb");
- ifstream recent (path.c_str());
-
- if (!recent) {
+ if (!fin) {
if (errno != ENOENT) {
error << string_compose (_("cannot open recent session file %1 (%2)"), path, strerror (errno)) << endmsg;
return -1;
@@ -59,6 +60,8 @@ ARDOUR::read_recent_sessions (RecentSessions& rs)
}
}
+ ifstream recent (fin);
+
while (true) {
pair<string,string> newpair;
@@ -82,6 +85,7 @@ ARDOUR::read_recent_sessions (RecentSessions& rs)
* natural order will be broken
*/
+ fclose (fin);
return 0;
}
@@ -120,18 +124,27 @@ ARDOUR::read_recent_templates (std::deque<std::string>& rt)
int
ARDOUR::write_recent_sessions (RecentSessions& rs)
{
- std::string path = Glib::build_filename (user_config_directory(), recent_file_name);
-
- ofstream recent (path.c_str());
+ FILE* fout = g_fopen (Glib::build_filename (user_config_directory(), recent_file_name).c_str(), "wb");
- if (!recent) {
+ if (!fout) {
return -1;
}
- for (RecentSessions::iterator i = rs.begin(); i != rs.end(); ++i) {
- recent << (*i).first << '\n' << (*i).second << endl;
+ {
+ ofstream recent (fout);
+
+ if (!recent) {
+ fclose (fout);
+ return -1;
+ }
+
+ for (RecentSessions::iterator i = rs.begin(); i != rs.end(); ++i) {
+ recent << (*i).first << '\n' << (*i).second << endl;
+ }
}
+ fclose (fout);
+
return 0;
}