summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorTim Mayberry <mojofunk@gmail.com>2007-06-07 03:25:00 +0000
committerTim Mayberry <mojofunk@gmail.com>2007-06-07 03:25:00 +0000
commita94bbda76c3b0ef29af9b3ab98865df77a818c0a (patch)
tree1a9958196daf0bbf31669ba9d2f2bffd75be8176 /libs
parent2c8d0460c2f99c2027d78c090b80d8df95d6f1e6 (diff)
Refactor Session::setup_raid_path Session::raid_path to use PBD::SearchPath
git-svn-id: svn://localhost/ardour2/trunk@1976 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r--libs/ardour/session_state.cc107
1 files changed, 27 insertions, 80 deletions
diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc
index 52bdcaf598..8d9bb55b59 100644
--- a/libs/ardour/session_state.cc
+++ b/libs/ardour/session_state.cc
@@ -55,6 +55,7 @@
#include <glibmm/thread.h>
#include <pbd/pathscanner.h>
#include <pbd/pthread_utils.h>
+#include <pbd/search_path.h>
#include <pbd/strsplit.h>
#include <pbd/stacktrace.h>
#include <pbd/copyfile.h>
@@ -359,108 +360,54 @@ Session::second_stage_init (bool new_session)
string
Session::raid_path () const
{
- string path;
+ SearchPath raid_search_path;
for (vector<space_and_path>::const_iterator i = session_dirs.begin(); i != session_dirs.end(); ++i) {
- path += (*i).path;
- path += ':';
+ raid_search_path += sys::path((*i).path);
}
- return path.substr (0, path.length() - 1); // drop final colon
+ return raid_search_path.get_string ();
}
void
Session::setup_raid_path (string path)
{
- string::size_type colon;
- string remaining;
- space_and_path sp;
- string fspath;
- string::size_type len = path.length();
- int colons;
-
- colons = 0;
-
- if (path.length() == 0) {
+ if (path.empty()) {
return;
}
+
+ space_and_path sp;
+ string fspath;
session_dirs.clear ();
- for (string::size_type n = 0; n < len; ++n) {
- if (path[n] == ':') {
- colons++;
- }
- }
-
- if (colons == 0) {
-
- /* no multiple search path, just one location (common case) */
-
- sp.path = path;
- sp.blocks = 0;
- session_dirs.push_back (sp);
-
- string fspath;
-
- /* sounds dir */
-
- fspath += sp.path;
- if (fspath[fspath.length()-1] != '/') {
- fspath += '/';
- }
-
- fspath += sound_dir (false);
-
- AudioFileSource::set_search_path (fspath);
- SMFSource::set_search_path (fspath); // FIXME: should be different
-
- return;
- }
-
- remaining = path;
+ SearchPath search_path(path);
+ SearchPath sound_search_path;
+ SearchPath midi_search_path;
- while ((colon = remaining.find_first_of (':')) != string::npos) {
-
- sp.blocks = 0;
- sp.path = remaining.substr (0, colon);
+ for (
+ SearchPath::const_iterator i = search_path.begin();
+ i != search_path.end();
+ ++i
+ )
+ {
+ sp.path = (*i).to_string ();
+ sp.blocks = 0; // not needed
session_dirs.push_back (sp);
- /* add sounds to file search path */
-
- fspath += sp.path;
- if (fspath[fspath.length()-1] != '/') {
- fspath += '/';
- }
- fspath += sound_dir (false);
- fspath += ':';
+ SessionDirectory sdir(sp.path);
- remaining = remaining.substr (colon+1);
+ sound_search_path += sdir.sound_path ();
+ midi_search_path += sdir.midi_path ();
}
- if (remaining.length()) {
+ // set the AudioFileSource and SMFSource search path
- sp.blocks = 0;
- sp.path = remaining;
-
- fspath += ':';
- fspath += sp.path;
- if (fspath[fspath.length()-1] != '/') {
- fspath += '/';
- }
- fspath += sound_dir (false);
- fspath += ':';
-
- session_dirs.push_back (sp);
- }
-
- /* set the AudioFileSource search path */
-
- AudioFileSource::set_search_path (fspath);
- SMFSource::set_search_path (fspath); // FIXME: should be different
-
- /* reset the round-robin soundfile path thingie */
+ AudioFileSource::set_search_path (sound_search_path.get_string ());
+ SMFSource::set_search_path (midi_search_path.get_string ());
+ // reset the round-robin soundfile path thingie
+
last_rr_session_dir = session_dirs.begin();
}