mirror of
https://github.com/Ardour/ardour.git
synced 2026-01-09 15:15:41 +01:00
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
This commit is contained in:
parent
506adcb7a2
commit
35c6b52c36
5 changed files with 90 additions and 1 deletions
|
|
@ -54,6 +54,17 @@ public:
|
|||
*/
|
||||
const std::string sound_path () const;
|
||||
|
||||
/**
|
||||
* @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
|
||||
|
|
@ -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:
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -102,6 +102,22 @@ SessionDirectory::sources_root () const
|
|||
return Glib::build_filename (sources_root_path, legalized_root);
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
|
|
@ -111,6 +127,12 @@ SessionDirectory::sound_path () const
|
|||
return Glib::build_filename (sources_root(), sound_dir_name);
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue