- if (Glib::file_test (full, Glib::FILE_TEST_IS_DIR|Glib::FILE_TEST_EXISTS)) {
- return res;
- }
-
- /* possibly support old session structure */
-
- string old_nopath;
- string old_withpath;
-
- old_nopath += old_sound_dir_name;
- old_nopath += '/';
-
- old_withpath = _path;
- old_withpath += old_sound_dir_name;
-
- if (Glib::file_test (old_withpath.c_str(), Glib::FILE_TEST_IS_DIR|Glib::FILE_TEST_EXISTS)) {
- if (with_path)
- return old_withpath;
-
- return old_nopath;
- }
-
- /* ok, old "sounds" directory isn't there, return the new path */
-
- return res;
-}
-
-string
-Session::midi_dir (bool with_path) const
-{
- string res;
- string full;
-
- if (with_path) {
- res = _path;
- } else {
- full = _path;
- }
-
- res += interchange_dir_name;
- res += '/';
- res += legalize_for_path (_name);
- res += '/';
- res += midi_dir_name;
-
- if (with_path) {
- full = res;
- } else {
- full += res;
- }
-
- return res;
-}
-
-string
-Session::peak_dir () const
-{
- string res = _path;
- res += peak_dir_name;
- res += '/';
- return res;
-}
-
-string
-Session::automation_dir () const
-{
- string res = _path;
- res += "automation/";
- return res;
-}
-
-string
-Session::template_dir ()
-{
- string path = get_user_ardour_path();
- path += "templates/";
-
- return path;
-}
-
-string
-Session::export_dir () const
-{
- string res = _path;
- res += export_dir_name;
- res += '/';
- return res;
-}
-
-string
-Session::suffixed_search_path (string suffix, bool data)
-{
- string path;
-
- path += get_user_ardour_path();
- if (path[path.length()-1] != ':') {
- path += ':';
- }
-
- if (data) {
- path += get_system_data_path();
- } else {
- path += get_system_module_path();
- }
-
- vector<string> split_path;
-
- split (path, split_path, ':');
- path = "";
-
- for (vector<string>::iterator i = split_path.begin(); i != split_path.end(); ++i) {
- path += *i;
- path += suffix;
- path += '/';
-
- if (distance (i, split_path.end()) != 1) {
- path += ':';
- }
- }
-
- return path;
-}
-
-string
-Session::template_path ()
-{
- return suffixed_search_path (templates_dir_name, true);
-}
-
-string
-Session::control_protocol_path ()
-{
- return suffixed_search_path (surfaces_dir_name, false);
-}
-
-int
-Session::load_bundles (const XMLNode& node)
-{
- XMLNodeList nlist = node.children();
- XMLNodeConstIterator niter;
-
- set_dirty();
-
- for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
- if ((*niter)->name() == "InputConnection") {
- add_bundle (new ARDOUR::InputBundle (**niter));
- } else if ((*niter)->name() == "OutputConnection") {
- add_bundle (new ARDOUR::OutputBundle (**niter));
- } else {
- error << string_compose(_("Unknown node \"%1\" found in Connections list from state file"), (*niter)->name()) << endmsg;
- return -1;
- }
- }
-
- return 0;
-}
-
-int
-Session::load_edit_groups (const XMLNode& node)
-{
- return load_route_groups (node, true);
-}
-
-int
-Session::load_mix_groups (const XMLNode& node)
-{
- return load_route_groups (node, false);
-}
-
-int
-Session::load_route_groups (const XMLNode& node, bool edit)
-{
- XMLNodeList nlist = node.children();
- XMLNodeConstIterator niter;
- RouteGroup* rg;
-
- set_dirty();
-
- for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
- if ((*niter)->name() == "RouteGroup") {
- if (edit) {
- rg = add_edit_group ("");
- rg->set_state (**niter);
- } else {
- rg = add_mix_group ("");
- rg->set_state (**niter);
- }
- }
- }
-
- return 0;
-}
-
-static bool
-state_file_filter (const string &str, void *arg)
-{
- return (str.length() > strlen(statefile_suffix) &&
- str.find (statefile_suffix) == (str.length() - strlen (statefile_suffix)));
-}
-
-struct string_cmp {
- bool operator()(const string* a, const string* b) {
- return *a < *b;
- }
-};
-
-static string*
-remove_end(string* state)
-{
- string statename(*state);
-
- string::size_type start,end;
- if ((start = statename.find_last_of ('/')) != string::npos) {
- statename = statename.substr (start+1);
- }
-