*/
+#include <cstring>
#include <cerrno>
#include <unistd.h>
#include <fstream>
#include <algorithm>
-#include <pbd/error.h>
-#include <ardour/configuration.h>
-#include <ardour/recent_sessions.h>
-#include <ardour/utils.h>
-#include "i18n.h"
+#include <glibmm/miscutils.h>
+
+#include "pbd/error.h"
+
+#include "ardour/configuration.h"
+#include "ardour/filesystem_paths.h"
+#include "ardour/recent_sessions.h"
+#include "ardour/utils.h"
+
+#include "i18n.h"
using namespace std;
using namespace ARDOUR;
+using namespace PBD;
+
+namespace {
+
+ const char * const recent_file_name = "recent";
+
+} // anonymous
int
ARDOUR::read_recent_sessions (RecentSessions& rs)
{
- string path = Config->get_user_ardour_path();
- path += "/recent";
+ sys::path recent_file_path(user_config_directory());
+
+ recent_file_path /= recent_file_name;
+
+ const string path = recent_file_path.to_string();
ifstream recent (path.c_str());
if (!recent) {
if (errno != ENOENT) {
- error << compose (_("cannot open recent session file %1 (%2)"), path, strerror (errno)) << endmsg;
+ error << string_compose (_("cannot open recent session file %1 (%2)"), path, strerror (errno)) << endmsg;
return -1;
} else {
return 1;
break;
}
- if (!access(newpair.second.c_str(), R_OK)) {
- rs.push_back (newpair);
- }
+ rs.push_back (newpair);
}
- // This deletes any missing sessions
- ARDOUR::write_recent_sessions (rs);
-
/* display sorting should be done in the GUI, otherwise the
* natural order will be broken
*/
- sort(rs.begin(), rs.end(), cmp);
-
return 0;
}
int
ARDOUR::write_recent_sessions (RecentSessions& rs)
{
- string path = Config->get_user_ardour_path();
- path += "/recent";
+ sys::path recent_file_path(user_config_directory());
+
+ recent_file_path /= recent_file_name;
+
+ const string path = recent_file_path.to_string();
ofstream recent (path.c_str());