Fixes for GCC 4.3.
[ardour.git] / libs / ardour / recent_sessions.cc
index c27ec223d6f399fe1a04d7f6b46ffccf9e6dc7bf..9b8668dd88b00699cb4b7d580e4e9e58a86eb056 100644 (file)
 
 */
 
+#include <cstring>
 #include <cerrno>
 #include <unistd.h>
 #include <fstream>
 #include <algorithm>
 #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"
 
+#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;
@@ -64,28 +76,24 @@ ARDOUR::read_recent_sessions (RecentSessions& rs)
                        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());