Use glibmm to simplify my earlier efforts with 'user_config_directory()' and 'user_ca...
[ardour.git] / libs / ardour / session_state.cc
index 59bb3fd718bc34e791b4fe8bd2842d9fd45b73be..47971bf633754cf2e3a62a67a28262f7054cabc3 100644 (file)
@@ -136,15 +136,8 @@ Session::pre_engine_init (string fullpath)
 
        /* discover canonical fullpath */
 
-       char buf[PATH_MAX+1];
-       if (!realpath (fullpath.c_str(), buf) && (errno != ENOENT)) {
-               error << string_compose(_("Could not use path %1 (%2)"), buf, strerror(errno)) << endmsg;
-               destroy ();
-               throw failed_constructor();
-       }
+       _path = canonical_path(fullpath);
 
-       _path = string(buf);
-       
        /* we require _path to end with a dir separator */
 
        if (_path[_path.length()-1] != G_DIR_SEPARATOR) {
@@ -1318,7 +1311,7 @@ Session::set_state (const XMLNode& node, int version)
        if ((child = find_named_node (node, "Click")) == 0) {
                warning << _("Session: XML state has no click section") << endmsg;
        } else if (_click_io) {
-               setup_click_state (node);
+               setup_click_state (&node);
        }
 
        if ((child = find_named_node (node, ControlProtocolManager::state_node_name)) != 0) {
@@ -2743,19 +2736,23 @@ Session::cleanup_sources (CleanupReport& rep)
                 ++tmp;
 
                if ((fs = boost::dynamic_pointer_cast<FileSource> (i->second)) != 0) {
-                        if (playlists->source_use_count (fs) != 0) {
-                                all_sources.insert (fs->path());
-                        } else {
 
-                                /* we might not remove this source from disk, because it may be used
-                                   by other snapshots, but its not being used in this version
-                                   so lets get rid of it now, along with any representative regions
-                                   in the region list.
-                                */
+                       if (!fs->is_stub()) {
 
-                                RegionFactory::remove_regions_using_source (i->second);
-                                sources.erase (i);
-                        }
+                               if (playlists->source_use_count (fs) != 0) {
+                                       all_sources.insert (fs->path());
+                               } else {
+                                       
+                                       /* we might not remove this source from disk, because it may be used
+                                          by other snapshots, but its not being used in this version
+                                          so lets get rid of it now, along with any representative regions
+                                          in the region list.
+                                       */
+                                       
+                                       RegionFactory::remove_regions_using_source (i->second);
+                                       sources.erase (i);
+                               }
+                       }
                }
 
                 i = tmp;
@@ -3483,22 +3480,6 @@ Session::config_changed (std::string p, bool ours)
                /* XXX DO SOMETHING HERE TO TELL THE GUI THAT WE NEED
                   TO SET REMOTE ID'S
                */
-       } else if (p == "sync-all-route-ordering") {
-
-               /* sync to editor order unless mixer is used for remote IDs 
-                */
-
-               switch (Config->get_remote_model()) {
-               case UserOrdered:
-                       sync_order_keys (EditorSort);
-                       break;
-               case EditorOrdered:
-                       sync_order_keys (EditorSort);
-                       break;
-               case MixerOrdered:
-                       sync_order_keys (MixerSort);
-               }
-                       
        } else if (p == "initial-program-change") {
 
                if (_mmc->output_port() && Config->get_initial_program_change() >= 0) {
@@ -3621,8 +3602,6 @@ Session::rename (const std::string& new_name)
 
        string const old_sources_root = _session_dir->sources_root();
 
-#define RENAME ::rename
-
        /* Rename:
 
         * session directory
@@ -3684,7 +3663,8 @@ Session::rename (const std::string& new_name)
 
                cerr << "Rename " << oldstr << " => " << newstr << endl;                
 
-               if (RENAME (oldstr.c_str(), newstr.c_str()) != 0) {
+               if (::g_rename (oldstr.c_str(), newstr.c_str()) != 0) {
+                       error << string_compose (_("renaming %s as %2 failed (%3)"), oldstr, newstr, g_strerror (errno)) << endmsg;
                        return 1;
                }
 
@@ -3711,7 +3691,8 @@ Session::rename (const std::string& new_name)
                
                cerr << "Rename " << oldstr << " => " << newstr << endl;
                
-               if (RENAME (oldstr.c_str(), newstr.c_str()) != 0) {
+               if (::g_rename (oldstr.c_str(), newstr.c_str()) != 0) {
+                       error << string_compose (_("renaming %s as %2 failed (%3)"), oldstr, newstr, g_strerror (errno)) << endmsg;
                        return 1;
                }
        }
@@ -3723,7 +3704,8 @@ Session::rename (const std::string& new_name)
        
        cerr << "Rename " << oldstr << " => " << newstr << endl;                
 
-       if (RENAME (oldstr.c_str(), newstr.c_str()) != 0) {
+       if (::g_rename (oldstr.c_str(), newstr.c_str()) != 0) {
+               error << string_compose (_("renaming %s as %2 failed (%3)"), oldstr, newstr, g_strerror (errno)) << endmsg;
                return 1;
        }
 
@@ -3737,7 +3719,8 @@ Session::rename (const std::string& new_name)
                
                cerr << "Rename " << oldstr << " => " << newstr << endl;                
                
-               if (RENAME (oldstr.c_str(), newstr.c_str()) != 0) {
+               if (::g_rename (oldstr.c_str(), newstr.c_str()) != 0) {
+                       error << string_compose (_("renaming %s as %2 failed (%3)"), oldstr, newstr, g_strerror (errno)) << endmsg;
                        return 1;
                }
        }
@@ -3773,8 +3756,6 @@ Session::rename (const std::string& new_name)
        store_recent_sessions (new_name, _path);
 
        return 0;
-
-#undef RENAME
 }
 
 int