Gracefully ignore plugins with no ports, or invalid ports.
[ardour.git] / libs / ardour / find_session.cc
index 90a54b1390d3354d5156518611977ce7223a05f7..4469b4e59de8a97f6061f340e53a5d67cdbfafb0 100644 (file)
@@ -5,10 +5,11 @@
 #include <climits>
 #include <cerrno>
 
+#include <glibmm/miscutils.h>
+
 #include "pbd/compose.h"
 #include "pbd/error.h"
 
-#include "ardour/session_utils.h"
 #include "ardour/filename_extensions.h"
 #include "ardour/utils.h"
 
 using namespace std;
 using namespace PBD;
 
+namespace ARDOUR {
+
 int
-ARDOUR::find_session (string str, string& path, string& snapshot, bool& isnew)
+find_session (string str, string& path, string& snapshot, bool& isnew)
 {
        struct stat statbuf;
        char buf[PATH_MAX+1];
@@ -53,17 +56,13 @@ ARDOUR::find_session (string str, string& path, string& snapshot, bool& isnew)
 
                if (S_ISDIR (statbuf.st_mode)) {
 
-                       string::size_type slash = str.find_last_of ('/');
+                       string::size_type slash = str.find_last_of (G_DIR_SEPARATOR);
 
                        if (slash == string::npos) {
 
                                /* a subdirectory of cwd, so statefile should be ... */
 
-                               string tmp;
-                               tmp = str;
-                               tmp += '/';
-                               tmp += str;
-                               tmp += statefile_suffix;
+                               string tmp = Glib::build_filename (str, str+statefile_suffix);
 
                                /* is it there ? */
 
@@ -90,7 +89,7 @@ ARDOUR::find_session (string str, string& path, string& snapshot, bool& isnew)
 
                } else if (S_ISREG (statbuf.st_mode)) {
 
-                       string::size_type slash = str.find_last_of ('/');
+                       string::size_type slash = str.find_last_of (G_DIR_SEPARATOR);
                        string::size_type suffix;
 
                        /* remove the suffix */
@@ -148,7 +147,7 @@ ARDOUR::find_session (string str, string& path, string& snapshot, bool& isnew)
                   as "dirname" does.
                */
 
-               string::size_type slash = str.find_last_of ('/');
+               string::size_type slash = str.find_last_of (G_DIR_SEPARATOR);
 
                if (slash == string::npos) {
 
@@ -166,3 +165,5 @@ ARDOUR::find_session (string str, string& path, string& snapshot, bool& isnew)
 
        return 0;
 }
+
+}  // namespace ARDOUR