Fix source directory paths so that the session name element is "legalized" and compat...
[ardour.git] / libs / ardour / session_directory.cc
index fcdaed3a29c93b6b2c9437e01b2296d9bdc47ac5..1a2b476cad5df8d6c6db74c5e76f2b01beabe56b 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <ardour/directory_names.h>
 #include <ardour/session_directory.h>
+#include <ardour/utils.h>
 
 #include "i18n.h"
 
@@ -85,20 +86,27 @@ SessionDirectory::old_sound_path () const
        return m_root_path / old_sound_dir_name;
 }
 
+const path
+SessionDirectory::sources_root () const
+{
+       const string legalized_root(legalize_for_path(m_root_path.leaf()));
+
+       return m_root_path / interchange_dir_name / legalized_root;
+}
+
 const path
 SessionDirectory::sound_path () const
 {
        if(is_directory (old_sound_path ())) return old_sound_path();
 
        // the new style sound directory
-       return m_root_path / interchange_dir_name / m_root_path.leaf() / sound_dir_name;
+       return sources_root() / sound_dir_name;
 }
 
 const path
 SessionDirectory::midi_path () const
 {
-       // the new style sound directory
-       return m_root_path / interchange_dir_name / m_root_path.leaf() / midi_dir_name;
+       return sources_root() / midi_dir_name;
 }
 
 const path