summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2011-12-07 18:52:14 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2011-12-07 18:52:14 +0000
commitae63588c0291f59ef3c14b331c5ec4d3c2f84f8e (patch)
tree2045d9ad4167ef0cb6adbac7d8bec5f02d70b43e
parent5ef06dd439088226683beff5c6fc1d5af55a014b (diff)
improved WORKING fix for search path issues
git-svn-id: svn://localhost/ardour2/branches/3.0@10940 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r--libs/ardour/ardour/session_configuration_vars.h4
-rw-r--r--libs/ardour/ardour/utils.h3
-rw-r--r--libs/ardour/session.cc83
-rw-r--r--libs/ardour/utils.cc28
4 files changed, 82 insertions, 36 deletions
diff --git a/libs/ardour/ardour/session_configuration_vars.h b/libs/ardour/ardour/session_configuration_vars.h
index 9d854ab2f8..45300d3e0f 100644
--- a/libs/ardour/ardour/session_configuration_vars.h
+++ b/libs/ardour/ardour/session_configuration_vars.h
@@ -43,8 +43,8 @@ CONFIG_VARIABLE (bool, punch_out, "punch-out", false)
CONFIG_VARIABLE (uint32_t, subframes_per_frame, "subframes-per-frame", 100)
CONFIG_VARIABLE (TimecodeFormat, timecode_format, "timecode-format", timecode_30)
CONFIG_VARIABLE_SPECIAL(std::string, raid_path, "raid-path", "", path_expand)
-CONFIG_VARIABLE_SPECIAL(std::string, audio_search_path, "audio-search-path", "", path_expand)
-CONFIG_VARIABLE_SPECIAL(std::string, midi_search_path, "midi-search-path", "", path_expand)
+CONFIG_VARIABLE_SPECIAL(std::string, audio_search_path, "audio-search-path", "", search_path_expand)
+CONFIG_VARIABLE_SPECIAL(std::string, midi_search_path, "midi-search-path", "", search_path_expand)
CONFIG_VARIABLE (std::string, bwf_country_code, "bwf-country-code", "US")
CONFIG_VARIABLE (std::string, bwf_organization_code, "bwf-organization-code", "US")
CONFIG_VARIABLE (LayerModel, layer_model, "layer-model", MoveAddHigher)
diff --git a/libs/ardour/ardour/utils.h b/libs/ardour/ardour/utils.h
index 17fa9070ff..03a2ff13b7 100644
--- a/libs/ardour/ardour/utils.h
+++ b/libs/ardour/ardour/utils.h
@@ -59,7 +59,8 @@ int cmp_nocase (const std::string& s, const std::string& s2);
int touch_file(std::string path);
-std::string path_expand (std::string);
+std::string path_expand (std::string); /* single file path */
+std::string search_path_expand (std::string); /* colon-separated search path */
std::string region_name_from_path (std::string path, bool strip_channels, bool add_channel_suffix = false, uint32_t total = 0, uint32_t this_one = 0);
bool path_is_paired (std::string path, std::string& pair_base);
diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc
index 2ad97e7d9d..d0ca765754 100644
--- a/libs/ardour/session.cc
+++ b/libs/ardour/session.cc
@@ -4216,9 +4216,32 @@ Session::end_time_changed (framepos_t old)
string
Session::source_search_path (DataType type) const
{
- string search_path;
+ vector<string> s;
+
+ if (session_dirs.size() == 1) {
+ switch (type) {
+ case DataType::AUDIO:
+ s.push_back ( _session_dir->sound_path().to_string());
+ break;
+ case DataType::MIDI:
+ s.push_back (_session_dir->midi_path().to_string());
+ break;
+ }
+ } else {
+ for (vector<space_and_path>::const_iterator i = session_dirs.begin(); i != session_dirs.end(); ++i) {
+ SessionDirectory sdir (i->path);
+ switch (type) {
+ case DataType::AUDIO:
+ s.push_back (sdir.sound_path().to_string());
+ break;
+ case DataType::MIDI:
+ s.push_back (sdir.midi_path().to_string());
+ break;
+ }
+ }
+ }
- /* first check the explicit (possibly user-specified) search path
+ /* now check the explicit (possibly user-specified) search path
*/
vector<string> dirs;
@@ -4233,41 +4256,27 @@ Session::source_search_path (DataType type) const
}
for (vector<string>::iterator i = dirs.begin(); i != dirs.end(); ++i) {
- search_path += ':';
- search_path += *i;
- }
-
- if (!search_path.empty()) {
- return search_path;
- }
+ vector<string>::iterator si;
- /* if there was nothing there, check the session dirs */
-
- if (session_dirs.size() == 1) {
- switch (type) {
- case DataType::AUDIO:
- search_path = _session_dir->sound_path().to_string();
- break;
- case DataType::MIDI:
- search_path = _session_dir->midi_path().to_string();
- break;
- }
- } else {
- for (vector<space_and_path>::const_iterator i = session_dirs.begin(); i != session_dirs.end(); ++i) {
- SessionDirectory sdir (i->path);
- if (!search_path.empty()) {
- search_path += ':';
- }
- switch (type) {
- case DataType::AUDIO:
- search_path += sdir.sound_path().to_string();
- break;
- case DataType::MIDI:
- search_path += sdir.midi_path().to_string();
+ for (si = s.begin(); si != s.end(); ++si) {
+ if ((*si) == *i) {
break;
}
}
+
+ if (si == s.end()) {
+ s.push_back (*i);
+ }
+ }
+
+ string search_path;
+
+ for (vector<string>::iterator si = s.begin(); si != s.end(); ++si) {
+ if (!search_path.empty()) {
+ search_path += ':';
+ }
+ search_path += *si;
}
return search_path;
@@ -4283,7 +4292,15 @@ Session::ensure_search_path_includes (const string& path, DataType type)
return;
}
- search_path = source_search_path (type);
+ switch (type) {
+ case DataType::AUDIO:
+ search_path = config.get_audio_search_path ();
+ break;
+ case DataType::MIDI:
+ search_path = config.get_midi_search_path ();
+ break;
+ }
+
split (search_path, dirs, ':');
for (vector<string>::iterator i = dirs.begin(); i != dirs.end(); ++i) {
diff --git a/libs/ardour/utils.cc b/libs/ardour/utils.cc
index afd83b62b5..8588d9ccd6 100644
--- a/libs/ardour/utils.cc
+++ b/libs/ardour/utils.cc
@@ -349,6 +349,34 @@ path_expand (string path)
}
}
+string
+search_path_expand (string path)
+{
+ if (path.empty()) {
+ return path;
+ }
+
+ vector<string> s;
+ vector<string> n;
+
+ split (path, s, ':');
+
+ for (vector<string>::iterator i = s.begin(); i != s.end(); ++i) {
+ n.push_back (path_expand (*i));
+ }
+
+ string r;
+
+ for (vector<string>::iterator i = n.begin(); i != n.end(); ++i) {
+ if (!r.empty()) {
+ r += ':';
+ }
+ r += *i;
+ }
+
+ return r;
+}
+
#if __APPLE__
string
CFStringRefToStdString(CFStringRef stringRef)