summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2012-10-23 14:52:26 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2012-10-23 14:52:26 +0000
commit35c6b52c36ca047ada5b1b127128c03049ebfc89 (patch)
tree0ae4967ae71420d94bf1053dbb44d725689d8734 /libs
parent506adcb7a2cd237cecdac151fd2682506a55ac89 (diff)
probable fix for not being able to find audio files in a 2.X session that had "illegal" characters in the session name - adds the 2.X version of the search path to the audio file search path, if it exists
git-svn-id: svn://localhost/ardour2/branches/3.0@13321 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r--libs/ardour/ardour/session_directory.h18
-rw-r--r--libs/ardour/ardour/utils.h1
-rw-r--r--libs/ardour/session.cc7
-rw-r--r--libs/ardour/session_directory.cc22
-rw-r--r--libs/ardour/utils.cc43
5 files changed, 90 insertions, 1 deletions
diff --git a/libs/ardour/ardour/session_directory.h b/libs/ardour/ardour/session_directory.h
index 6f8f24386f..9f4410ce69 100644
--- a/libs/ardour/ardour/session_directory.h
+++ b/libs/ardour/ardour/session_directory.h
@@ -56,6 +56,17 @@ public:
/**
* @return the absolute path to the directory in which
+ * the session stores audio files for Ardour 2.X.
+ *
+ * If the session is an older session with an existing
+ * "sounds" directory then it will return a path to that
+ * directory otherwise it will return the new location
+ * of root_path()/interchange/session_name/audiofiles
+ */
+ const std::string sound_path_2X () const;
+
+ /**
+ * @return the absolute path to the directory in which
* the session stores MIDI files, ie
* root_path()/interchange/session_name/midifiles
*/
@@ -110,6 +121,13 @@ public:
*/
const std::string sources_root() const;
+ /**
+ * @return The path to the directory under which source directories
+ * are created for different source types in Ardour 2.X
+ * i.e root_path()/interchange/session_name
+ */
+ const std::string sources_root_2X() const;
+
private:
/**
diff --git a/libs/ardour/ardour/utils.h b/libs/ardour/ardour/utils.h
index 5052f03bab..7a09f5e209 100644
--- a/libs/ardour/ardour/utils.h
+++ b/libs/ardour/ardour/utils.h
@@ -39,6 +39,7 @@
class XMLNode;
std::string legalize_for_path (const std::string& str);
+std::string legalize_for_path_2X (const std::string& str);
XMLNode* find_named_node (const XMLNode& node, std::string name);
std::string bool_as_string (bool);
diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc
index e742dd372f..8c36f95726 100644
--- a/libs/ardour/session.cc
+++ b/libs/ardour/session.cc
@@ -4352,6 +4352,13 @@ Session::source_search_path (DataType type) const
}
}
+ if (type == DataType::AUDIO) {
+ const string sound_path_2X = _session_dir->sound_path_2X();
+ if (Glib::file_test (sound_path_2X, Glib::FILE_TEST_EXISTS|Glib::FILE_TEST_IS_DIR)) {
+ s.push_back (sound_path_2X);
+ }
+ }
+
/* now check the explicit (possibly user-specified) search path
*/
diff --git a/libs/ardour/session_directory.cc b/libs/ardour/session_directory.cc
index ec4fded685..7ff9c6f5a7 100644
--- a/libs/ardour/session_directory.cc
+++ b/libs/ardour/session_directory.cc
@@ -103,6 +103,22 @@ SessionDirectory::sources_root () const
}
const std::string
+SessionDirectory::sources_root_2X () const
+{
+ std::string p = m_root_path;
+ std::string filename = Glib::path_get_basename(p);
+
+ if (filename == ".") {
+ p = PBD::get_absolute_path (m_root_path);
+ }
+
+ const string legalized_root (legalize_for_path_2X (Glib::path_get_basename(p)));
+
+ std::string sources_root_path = Glib::build_filename (m_root_path, interchange_dir_name);
+ return Glib::build_filename (sources_root_path, legalized_root);
+}
+
+const std::string
SessionDirectory::sound_path () const
{
if (Glib::file_test (old_sound_path (), Glib::FILE_TEST_IS_DIR)) return old_sound_path();
@@ -112,6 +128,12 @@ SessionDirectory::sound_path () const
}
const std::string
+SessionDirectory::sound_path_2X () const
+{
+ return Glib::build_filename (sources_root_2X(), sound_dir_name);
+}
+
+const std::string
SessionDirectory::midi_path () const
{
return Glib::build_filename (sources_root(), midi_dir_name);
diff --git a/libs/ardour/utils.cc b/libs/ardour/utils.cc
index 8c990a5e88..d9310c958a 100644
--- a/libs/ardour/utils.cc
+++ b/libs/ardour/utils.cc
@@ -60,12 +60,23 @@ using namespace ARDOUR;
using namespace std;
using namespace PBD;
+/** take an arbitrary string as an argument, and return a version of it
+ * suitable for use as a path (directory/folder name). This is the Ardour 3.X
+ * and later version of this code. It defines a very small number
+ * of characters that are not allowed in a path on any of our target
+ * filesystems, and replaces any instances of them with an underscore.
+ */
+
string
legalize_for_path (const string& str)
{
string::size_type pos;
string illegal_chars = "/\\"; /* DOS, POSIX. Yes, we're going to ignore HFS */
- string legal;
+ Glib::ustring legal;
+
+ /* this is the one place in Ardour where we need to iterate across
+ * potential multibyte characters, and thus we need Glib::ustring
+ */
legal = str;
pos = 0;
@@ -78,6 +89,36 @@ legalize_for_path (const string& str)
return string (legal);
}
+/** take an arbitrary string as an argument, and return a version of it
+ * suitable for use as a path (directory/folder name). This is the Ardour 2.X
+ * version of this code, which used an approach that came to be seen as
+ * problematic: defining the characters that were allowed and replacing all
+ * others with underscores. See legalize_for_path() for the 3.X and later
+ * version.
+ */
+
+string
+legalize_for_path_2X (const string& str)
+{
+ string::size_type pos;
+ string legal_chars = "abcdefghijklmnopqrtsuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_+=: ";
+ Glib::ustring legal;
+
+ /* this is the one place in Ardour where we need to iterate across
+ * potential multibyte characters, and thus we need Glib::ustring
+ */
+
+ legal = str;
+ pos = 0;
+
+ while ((pos = legal.find_first_not_of (legal_chars, pos)) != string::npos) {
+ legal.replace (pos, 1, "_");
+ pos += 1;
+ }
+
+ return string (legal);
+}
+
string
bump_name_once (const std::string& name, char delimiter)
{