mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-22 14:46:34 +01:00
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
This commit is contained in:
parent
2c8d0460c2
commit
a94bbda76c
1 changed files with 27 additions and 80 deletions
|
|
@ -55,6 +55,7 @@
|
||||||
#include <glibmm/thread.h>
|
#include <glibmm/thread.h>
|
||||||
#include <pbd/pathscanner.h>
|
#include <pbd/pathscanner.h>
|
||||||
#include <pbd/pthread_utils.h>
|
#include <pbd/pthread_utils.h>
|
||||||
|
#include <pbd/search_path.h>
|
||||||
#include <pbd/strsplit.h>
|
#include <pbd/strsplit.h>
|
||||||
#include <pbd/stacktrace.h>
|
#include <pbd/stacktrace.h>
|
||||||
#include <pbd/copyfile.h>
|
#include <pbd/copyfile.h>
|
||||||
|
|
@ -359,107 +360,53 @@ Session::second_stage_init (bool new_session)
|
||||||
string
|
string
|
||||||
Session::raid_path () const
|
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) {
|
for (vector<space_and_path>::const_iterator i = session_dirs.begin(); i != session_dirs.end(); ++i) {
|
||||||
path += (*i).path;
|
raid_search_path += sys::path((*i).path);
|
||||||
path += ':';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return path.substr (0, path.length() - 1); // drop final colon
|
return raid_search_path.get_string ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Session::setup_raid_path (string path)
|
Session::setup_raid_path (string path)
|
||||||
{
|
{
|
||||||
string::size_type colon;
|
if (path.empty()) {
|
||||||
string remaining;
|
|
||||||
space_and_path sp;
|
|
||||||
string fspath;
|
|
||||||
string::size_type len = path.length();
|
|
||||||
int colons;
|
|
||||||
|
|
||||||
colons = 0;
|
|
||||||
|
|
||||||
if (path.length() == 0) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
space_and_path sp;
|
||||||
|
string fspath;
|
||||||
|
|
||||||
session_dirs.clear ();
|
session_dirs.clear ();
|
||||||
|
|
||||||
for (string::size_type n = 0; n < len; ++n) {
|
SearchPath search_path(path);
|
||||||
if (path[n] == ':') {
|
SearchPath sound_search_path;
|
||||||
colons++;
|
SearchPath midi_search_path;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (colons == 0) {
|
for (
|
||||||
|
SearchPath::const_iterator i = search_path.begin();
|
||||||
/* no multiple search path, just one location (common case) */
|
i != search_path.end();
|
||||||
|
++i
|
||||||
sp.path = path;
|
)
|
||||||
sp.blocks = 0;
|
{
|
||||||
|
sp.path = (*i).to_string ();
|
||||||
|
sp.blocks = 0; // not needed
|
||||||
session_dirs.push_back (sp);
|
session_dirs.push_back (sp);
|
||||||
|
|
||||||
string fspath;
|
SessionDirectory sdir(sp.path);
|
||||||
|
|
||||||
/* sounds dir */
|
sound_search_path += sdir.sound_path ();
|
||||||
|
midi_search_path += sdir.midi_path ();
|
||||||
fspath += sp.path;
|
|
||||||
if (fspath[fspath.length()-1] != '/') {
|
|
||||||
fspath += '/';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fspath += sound_dir (false);
|
// set the AudioFileSource and SMFSource search path
|
||||||
|
|
||||||
AudioFileSource::set_search_path (fspath);
|
AudioFileSource::set_search_path (sound_search_path.get_string ());
|
||||||
SMFSource::set_search_path (fspath); // FIXME: should be different
|
SMFSource::set_search_path (midi_search_path.get_string ());
|
||||||
|
|
||||||
return;
|
// reset the round-robin soundfile path thingie
|
||||||
}
|
|
||||||
|
|
||||||
remaining = path;
|
|
||||||
|
|
||||||
while ((colon = remaining.find_first_of (':')) != string::npos) {
|
|
||||||
|
|
||||||
sp.blocks = 0;
|
|
||||||
sp.path = remaining.substr (0, colon);
|
|
||||||
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 += ':';
|
|
||||||
|
|
||||||
remaining = remaining.substr (colon+1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (remaining.length()) {
|
|
||||||
|
|
||||||
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 */
|
|
||||||
|
|
||||||
last_rr_session_dir = session_dirs.begin();
|
last_rr_session_dir = session_dirs.begin();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue