diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index 8a8e8e72e3..60fa9e5761 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -173,6 +173,7 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop virtual ~Session (); static int get_info_from_path (const std::string& xmlpath, float& sample_rate, SampleFormat& data_format); + static std::string get_snapshot_from_instant (const std::string& session_dir); std::string path() const { return _path; } std::string name() const { return _name; } diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index 9e8f8dcf2d..48bacdfe07 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -4216,6 +4216,29 @@ Session::get_info_from_path (const string& xmlpath, float& sample_rate, SampleFo return !(found_sr && found_data_format); // zero if they are both found } +std::string +Session::get_snapshot_from_instant (const std::string& session_dir) +{ + std::string instant_xml_path = Glib::build_filename (session_dir, "instant.xml"); + + if (!Glib::file_test (instant_xml_path, Glib::FILE_TEST_EXISTS)) { + return ""; + } + + XMLTree tree; + if (!tree.read (instant_xml_path)) { + return ""; + } + + const XMLProperty* prop; + XMLNode *last_used_snapshot = tree.root()->child("LastUsedSnapshot"); + if (last_used_snapshot && (prop = last_used_snapshot->property ("name")) != 0) { + return prop->value(); + } + + return ""; +} + typedef std::vector > SeveralFileSources; typedef std::map SourcePathMap;