X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=libs%2Fardour%2Ffind_session.cc;h=c635b86545ad442c457d76d6290f0c0e9fa76f91;hb=39f765614a7964e07c55a57ba854f8524807d6cb;hp=4388d8e2991a341927be2bab4ad2ff0b9d80d6d5;hpb=449aab3c465bbbf66d221fac3d7ea559f1720357;p=ardour.git diff --git a/libs/ardour/find_session.cc b/libs/ardour/find_session.cc index 4388d8e299..c635b86545 100644 --- a/libs/ardour/find_session.cc +++ b/libs/ardour/find_session.cc @@ -5,15 +5,18 @@ #include #include -#include -#include +#include -#include -#include -#include +#include "pbd/compose.h" +#include "pbd/error.h" + +#include "ardour/session_utils.h" +#include "ardour/filename_extensions.h" +#include "ardour/utils.h" #include "i18n.h" +using namespace std; using namespace PBD; int @@ -30,7 +33,7 @@ ARDOUR::find_session (string str, string& path, string& snapshot, bool& isnew) } str = buf; - + /* check to see if it exists, and what it is */ if (stat (str.c_str(), &statbuf)) { @@ -52,20 +55,16 @@ 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 ? */ - + if (stat (tmp.c_str(), &statbuf)) { error << string_compose (_("cannot check statefile %1 (%2)"), tmp, strerror (errno)) << endmsg; @@ -84,16 +83,16 @@ ARDOUR::find_session (string str, string& path, string& snapshot, bool& isnew) path = str; snapshot = str.substr (slash+1); - + } } 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 */ - + if (slash != string::npos) { snapshot = str.substr (slash+1); } else { @@ -101,19 +100,19 @@ ARDOUR::find_session (string str, string& path, string& snapshot, bool& isnew) } suffix = snapshot.find (statefile_suffix); - + if (suffix == string::npos) { - error << string_compose (_("%1 is not an Ardour snapshot file"), str) << endmsg; + error << string_compose (_("%1 is not a snapshot file"), str) << endmsg; return -1; } /* remove suffix */ snapshot = snapshot.substr (0, suffix); - + if (slash == string::npos) { - - /* we must be in the directory where the + + /* we must be in the directory where the statefile lives. get it using cwd(). */ @@ -133,7 +132,7 @@ ARDOUR::find_session (string str, string& path, string& snapshot, bool& isnew) path = str.substr (0, slash); } - + } else { /* what type of file is it? */ @@ -147,17 +146,17 @@ 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) { - + /* no slash, just use the name, but clean it up */ - + path = legalize_for_path (str); snapshot = path; - + } else { - + path = str; snapshot = str.substr (slash+1); }