Use std::string instead of PBD::sys::path in pbd/search_path.h, pbd/file_utils.h and ardour/session_dir.h

git-svn-id: svn://localhost/ardour2/branches/3.0@12829 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Tim Mayberry 2012-06-23 05:06:54 +00:00
parent 22e478e7fc
commit 105caf23da
54 changed files with 255 additions and 309 deletions

View file

@ -553,15 +553,14 @@ About::About ()
{ {
// set_type_hint(Gdk::WINDOW_TYPE_HINT_SPLASHSCREEN); // set_type_hint(Gdk::WINDOW_TYPE_HINT_SPLASHSCREEN);
string path;
string t; string t;
sys::path splash_file; std::string splash_file;
SearchPath spath(ardour_data_search_path()); SearchPath spath(ardour_data_search_path());
if (find_file_in_search_path (spath, "splash.png", splash_file)) { if (find_file_in_search_path (spath, "splash.png", splash_file)) {
set_logo (Gdk::Pixbuf::create_from_file (splash_file.to_string())); set_logo (Gdk::Pixbuf::create_from_file (splash_file));
} else { } else {
error << "Could not find splash file" << endmsg; error << "Could not find splash file" << endmsg;
} }

View file

@ -67,7 +67,7 @@ vector<RefPtr<Gtk::Action> > ActionManager::edit_point_in_region_sensitive_actio
void void
ActionManager::init () ActionManager::init ()
{ {
sys::path ui_file; std::string ui_file;
ui_manager = UIManager::create (); ui_manager = UIManager::create ();
@ -76,8 +76,8 @@ ActionManager::init ()
bool loaded = false; bool loaded = false;
try { try {
ui_manager->add_ui_from_file (ui_file.to_string()); ui_manager->add_ui_from_file (ui_file);
info << string_compose (_("Loading menus from %1"), ui_file.to_string()) << endmsg; info << string_compose (_("Loading menus from %1"), ui_file) << endmsg;
loaded = true; loaded = true;
} catch (Glib::MarkupError& err) { } catch (Glib::MarkupError& err) {
error << string_compose (_("badly formatted UI definition file: %1"), err.what()) << endmsg; error << string_compose (_("badly formatted UI definition file: %1"), err.what()) << endmsg;

View file

@ -1134,11 +1134,11 @@ ARDOUR_UI::redisplay_recent_sessions ()
for (vector<sys::path>::const_iterator i = session_directories.begin(); for (vector<sys::path>::const_iterator i = session_directories.begin();
i != session_directories.end(); ++i) i != session_directories.end(); ++i)
{ {
std::vector<sys::path> state_file_paths; std::vector<std::string> state_file_paths;
// now get available states for this session // now get available states for this session
get_state_files_in_directory (*i, state_file_paths); get_state_files_in_directory (i->to_string(), state_file_paths);
vector<string*>* states; vector<string*>* states;
vector<const gchar*> item; vector<const gchar*> item;
@ -2074,7 +2074,7 @@ ARDOUR_UI::snapshot_session (bool switch_to_it)
} }
} }
vector<sys::path> p; vector<std::string> p;
get_state_files_in_directory (_session->session_directory().root_path(), p); get_state_files_in_directory (_session->session_directory().root_path(), p);
vector<string> n = get_file_names_no_extension (p); vector<string> n = get_file_names_no_extension (p);
if (find (n.begin(), n.end(), snapname) != n.end()) { if (find (n.begin(), n.end(), snapname) != n.end()) {
@ -2913,7 +2913,7 @@ require some unused files to continue to exist."));
dimage->set_alignment(ALIGN_LEFT, ALIGN_TOP); dimage->set_alignment(ALIGN_LEFT, ALIGN_TOP);
const string dead_directory = _session->session_directory().dead_path().to_string(); const string dead_directory = _session->session_directory().dead_path();
/* subst: /* subst:
%1 - number of files removed %1 - number of files removed

View file

@ -641,11 +641,11 @@ Editor::load_bindings ()
key_bindings.set_action_map (editor_action_map); key_bindings.set_action_map (editor_action_map);
sys::path binding_file; std::string binding_file;
if (find_file_in_search_path (ardour_config_search_path(), "editor.bindings", binding_file)) { if (find_file_in_search_path (ardour_config_search_path(), "editor.bindings", binding_file)) {
key_bindings.load (binding_file.to_string()); key_bindings.load (binding_file);
info << string_compose (_("Loaded editor bindings from %1"), binding_file.to_string()) << endmsg; info << string_compose (_("Loaded editor bindings from %1"), binding_file) << endmsg;
} else { } else {
error << string_compose (_("Could not find editor.bindings in search path %1"), ardour_config_search_path().to_string()) << endmsg; error << string_compose (_("Could not find editor.bindings in search path %1"), ardour_config_search_path().to_string()) << endmsg;
} }

View file

@ -232,7 +232,7 @@ Editor::write_region (string path, boost::shared_ptr<AudioRegion> region)
vector<boost::shared_ptr<AudioFileSource> > sources; vector<boost::shared_ptr<AudioFileSource> > sources;
uint32_t nchans; uint32_t nchans;
const string sound_directory = _session->session_directory().sound_path().to_string(); const string sound_directory = _session->session_directory().sound_path();
nchans = region->n_channels(); nchans = region->n_channels();
@ -382,7 +382,7 @@ Editor::write_audio_range (AudioPlaylist& playlist, const ChanCount& count, list
string path; string path;
vector<boost::shared_ptr<AudioFileSource> > sources; vector<boost::shared_ptr<AudioFileSource> > sources;
const string sound_directory = _session->session_directory().sound_path().to_string(); const string sound_directory = _session->session_directory().sound_path();
uint32_t channels = count.n_audio(); uint32_t channels = count.n_audio();

View file

@ -173,7 +173,7 @@ EditorSnapshots::redisplay ()
return; return;
} }
vector<sys::path> state_file_paths; vector<std::string> state_file_paths;
get_state_files_in_directory (_session->session_directory().root_path(), get_state_files_in_directory (_session->session_directory().root_path(),
state_file_paths); state_file_paths);

View file

@ -19,6 +19,7 @@
#include "pbd/error.h" #include "pbd/error.h"
#include "pbd/file_utils.h" #include "pbd/file_utils.h"
#include "pbd/filesystem.h"
#include "ardour/filesystem_paths.h" #include "ardour/filesystem_paths.h"
@ -124,7 +125,7 @@ ArdourKeyboard::setup_keybindings ()
if (!Glib::path_is_absolute (keybindings_path)) { if (!Glib::path_is_absolute (keybindings_path)) {
/* not absolute - look in the usual places */ /* not absolute - look in the usual places */
sys::path keybindings_file; std::string keybindings_file;
if ( ! find_file_in_search_path (ardour_config_search_path(), keybindings_path, keybindings_file)) { if ( ! find_file_in_search_path (ardour_config_search_path(), keybindings_path, keybindings_file)) {
@ -142,7 +143,7 @@ ArdourKeyboard::setup_keybindings ()
/* use it */ /* use it */
keybindings_path = keybindings_file.to_string(); keybindings_path = keybindings_file;
break; break;
} }

View file

@ -222,7 +222,7 @@ fixup_bundle_environment (int /*argc*/, char* argv[])
std::string path; std::string path;
std::string dir_path = Glib::path_get_dirname (Glib::path_get_dirname (argv[0])); std::string dir_path = Glib::path_get_dirname (Glib::path_get_dirname (argv[0]));
std::string userconfigdir = user_config_directory().to_string(); std::string userconfigdir = user_config_directory();
/* note that this function is POSIX/Linux specific, so using / as /* note that this function is POSIX/Linux specific, so using / as
a dir separator in this context is just fine. a dir separator in this context is just fine.

View file

@ -82,11 +82,11 @@ MixerActor::load_bindings ()
bindings.set_action_map (myactions); bindings.set_action_map (myactions);
sys::path binding_file; std::string binding_file;
if (find_file_in_search_path (ardour_config_search_path(), "mixer.bindings", binding_file)) { if (find_file_in_search_path (ardour_config_search_path(), "mixer.bindings", binding_file)) {
bindings.load (binding_file.to_string()); bindings.load (binding_file);
info << string_compose (_("Loaded mixer bindings from %1"), binding_file.to_string()) << endmsg; info << string_compose (_("Loaded mixer bindings from %1"), binding_file) << endmsg;
} else { } else {
error << string_compose (_("Could not find mixer.bindings in search path %1"), ardour_config_search_path().to_string()) << endmsg; error << string_compose (_("Could not find mixer.bindings in search path %1"), ardour_config_search_path().to_string()) << endmsg;
} }

View file

@ -94,7 +94,7 @@ NagScreen::maybe_nag (std::string why)
bool really_subscribed; bool really_subscribed;
bool maybe_subscribed; bool maybe_subscribed;
path = Glib::build_filename (user_config_directory().to_string(), ".nevernag"); path = Glib::build_filename (user_config_directory(), ".nevernag");
if (Glib::file_test (path, Glib::FILE_TEST_EXISTS)) { if (Glib::file_test (path, Glib::FILE_TEST_EXISTS)) {
return 0; return 0;
@ -114,7 +114,7 @@ NagScreen::mark_never_again ()
{ {
std::string path; std::string path;
path = Glib::build_filename (user_config_directory().to_string(), ".nevernag"); path = Glib::build_filename (user_config_directory(), ".nevernag");
ofstream nagfile (path.c_str()); ofstream nagfile (path.c_str());
} }
@ -124,7 +124,7 @@ NagScreen::mark_subscriber ()
{ {
std::string path; std::string path;
path = Glib::build_filename (user_config_directory().to_string(), ".askedaboutsub"); path = Glib::build_filename (user_config_directory(), ".askedaboutsub");
ofstream subsfile (path.c_str()); ofstream subsfile (path.c_str());
} }
@ -134,7 +134,7 @@ NagScreen::mark_affirmed_subscriber ()
{ {
std::string path; std::string path;
path = Glib::build_filename (user_config_directory().to_string(), ".isubscribe"); path = Glib::build_filename (user_config_directory(), ".isubscribe");
ofstream subsfile (path.c_str()); ofstream subsfile (path.c_str());
} }
@ -152,13 +152,13 @@ NagScreen::is_subscribed (bool& really)
subscribed. we try to trust our users :) subscribed. we try to trust our users :)
*/ */
path = Glib::build_filename (user_config_directory().to_string(), ".isubscribe"); path = Glib::build_filename (user_config_directory(), ".isubscribe");
if (file_test (path, FILE_TEST_EXISTS)) { if (file_test (path, FILE_TEST_EXISTS)) {
really = true; really = true;
return true; return true;
} }
path = Glib::build_filename (user_config_directory().to_string(), ".askedaboutsub"); path = Glib::build_filename (user_config_directory(), ".askedaboutsub");
if (file_test (path, FILE_TEST_EXISTS)) { if (file_test (path, FILE_TEST_EXISTS)) {
/* they never said they were subscribed but they /* they never said they were subscribed but they
did once express an interest in it. did once express an interest in it.

View file

@ -1301,8 +1301,7 @@ SoundFileOmega::check_info (const vector<string>& paths, bool& same_size, bool&
bool bool
SoundFileOmega::check_link_status (const Session* s, const vector<string>& paths) SoundFileOmega::check_link_status (const Session* s, const vector<string>& paths)
{ {
sys::path path = s->session_directory().sound_path() / "linktest"; std::string tmpdir(Glib::build_filename (s->session_directory().sound_path(), "linktest"));
string tmpdir = path.to_string();
bool ret = false; bool ret = false;
if (mkdir (tmpdir.c_str(), 0744)) { if (mkdir (tmpdir.c_str(), 0744)) {

View file

@ -41,14 +41,14 @@ Splash::Splash ()
{ {
assert (the_splash == 0); assert (the_splash == 0);
sys::path splash_file; std::string splash_file;
if (!find_file_in_search_path (ardour_data_search_path(), "splash.png", splash_file)) { if (!find_file_in_search_path (ardour_data_search_path(), "splash.png", splash_file)) {
throw failed_constructor(); throw failed_constructor();
} }
try { try {
pixbuf = Gdk::Pixbuf::create_from_file (splash_file.to_string()); pixbuf = Gdk::Pixbuf::create_from_file (splash_file);
} }
catch (...) { catch (...) {

View file

@ -933,11 +933,11 @@ ArdourStartup::redisplay_recent_sessions ()
for (vector<sys::path>::const_iterator i = session_directories.begin(); i != session_directories.end(); ++i) for (vector<sys::path>::const_iterator i = session_directories.begin(); i != session_directories.end(); ++i)
{ {
std::vector<sys::path> state_file_paths; std::vector<std::string> state_file_paths;
// now get available states for this session // now get available states for this session
get_state_files_in_directory (*i, state_file_paths); get_state_files_in_directory ((*i).to_string (), state_file_paths);
vector<string*>* states; vector<string*>* states;
vector<const gchar*> item; vector<const gchar*> item;

View file

@ -708,10 +708,10 @@ StepEntry::load_bindings ()
bindings.set_action_map (myactions); bindings.set_action_map (myactions);
sys::path binding_file; std::string binding_file;
if (find_file_in_search_path (ardour_config_search_path(), "step_editing.bindings", binding_file)) { if (find_file_in_search_path (ardour_config_search_path(), "step_editing.bindings", binding_file)) {
bindings.load (binding_file.to_string()); bindings.load (binding_file);
} }
} }

View file

@ -202,7 +202,7 @@ ThemeManager::button_press_event (GdkEventButton* ev)
void void
load_rc_file (const string& filename, bool themechange) load_rc_file (const string& filename, bool themechange)
{ {
sys::path rc_file_path; std::string rc_file_path;
if (!find_file_in_search_path (ardour_config_search_path(), filename, rc_file_path)) { if (!find_file_in_search_path (ardour_config_search_path(), filename, rc_file_path)) {
warning << string_compose (_("Unable to find UI style file %1 in search path %2. %3 will look strange"), warning << string_compose (_("Unable to find UI style file %1 in search path %2. %3 will look strange"),
@ -211,9 +211,9 @@ load_rc_file (const string& filename, bool themechange)
return; return;
} }
info << "Loading ui configuration file " << rc_file_path.to_string() << endmsg; info << "Loading ui configuration file " << rc_file_path << endmsg;
Gtkmm2ext::UI::instance()->load_rcfile (rc_file_path.to_string(), themechange); Gtkmm2ext::UI::instance()->load_rcfile (rc_file_path, themechange);
} }
/* hmm, this is a problem. the profile doesn't /* hmm, this is a problem. the profile doesn't

View file

@ -65,7 +65,7 @@ UIConfiguration::load_defaults ()
{ {
int found = 0; int found = 0;
sys::path default_ui_rc_file; std::string default_ui_rc_file;
std::string rcfile; std::string rcfile;
if (getenv ("ARDOUR_SAE")) { if (getenv ("ARDOUR_SAE")) {
@ -78,7 +78,7 @@ UIConfiguration::load_defaults ()
XMLTree tree; XMLTree tree;
found = 1; found = 1;
string rcfile = default_ui_rc_file.to_string(); string rcfile = default_ui_rc_file;
info << string_compose (_("Loading default ui configuration file %1"), rcfile) << endl; info << string_compose (_("Loading default ui configuration file %1"), rcfile) << endl;
@ -103,13 +103,13 @@ UIConfiguration::load_state ()
{ {
bool found = false; bool found = false;
sys::path default_ui_rc_file; std::string default_ui_rc_file;
if ( find_file_in_search_path (ardour_config_search_path(), "ardour3_ui_default.conf", default_ui_rc_file)) { if ( find_file_in_search_path (ardour_config_search_path(), "ardour3_ui_default.conf", default_ui_rc_file)) {
XMLTree tree; XMLTree tree;
found = true; found = true;
string rcfile = default_ui_rc_file.to_string(); string rcfile = default_ui_rc_file;
info << string_compose (_("Loading default ui configuration file %1"), rcfile) << endl; info << string_compose (_("Loading default ui configuration file %1"), rcfile) << endl;
@ -124,13 +124,13 @@ UIConfiguration::load_state ()
} }
} }
sys::path user_ui_rc_file; std::string user_ui_rc_file;
if (find_file_in_search_path (ardour_config_search_path(), "ardour3_ui.conf", user_ui_rc_file)) { if (find_file_in_search_path (ardour_config_search_path(), "ardour3_ui.conf", user_ui_rc_file)) {
XMLTree tree; XMLTree tree;
found = true; found = true;
string rcfile = user_ui_rc_file.to_string(); string rcfile = user_ui_rc_file;
info << string_compose (_("Loading user ui configuration file %1"), rcfile) << endmsg; info << string_compose (_("Loading user ui configuration file %1"), rcfile) << endmsg;

View file

@ -498,14 +498,14 @@ get_xpm (std::string name)
spath.add_subdirectory_to_paths("pixmaps"); spath.add_subdirectory_to_paths("pixmaps");
sys::path data_file_path; std::string data_file_path;
if(!find_file_in_search_path (spath, name, data_file_path)) { if(!find_file_in_search_path (spath, name, data_file_path)) {
fatal << string_compose (_("cannot find XPM file for %1"), name) << endmsg; fatal << string_compose (_("cannot find XPM file for %1"), name) << endmsg;
} }
try { try {
xpm_map[name] = Gdk::Pixbuf::create_from_file (data_file_path.to_string()); xpm_map[name] = Gdk::Pixbuf::create_from_file (data_file_path);
} catch(const Glib::Error& e) { } catch(const Glib::Error& e) {
warning << "Caught Glib::Error: " << e.what() << endmsg; warning << "Caught Glib::Error: " << e.what() << endmsg;
} }
@ -524,13 +524,13 @@ get_icon_path (const char* cname)
spath.add_subdirectory_to_paths("icons"); spath.add_subdirectory_to_paths("icons");
sys::path data_file_path; std::string data_file_path;
if (!find_file_in_search_path (spath, name, data_file_path)) { if (!find_file_in_search_path (spath, name, data_file_path)) {
fatal << string_compose (_("cannot find icon image for %1 using %2"), name, spath.to_string()) << endmsg; fatal << string_compose (_("cannot find icon image for %1 using %2"), name, spath.to_string()) << endmsg;
} }
return data_file_path.to_string(); return data_file_path;
} }
Glib::RefPtr<Gdk::Pixbuf> Glib::RefPtr<Gdk::Pixbuf>

View file

@ -32,6 +32,7 @@
#include "pbd/uuid.h" #include "pbd/uuid.h"
#include "pbd/file_utils.h" #include "pbd/file_utils.h"
#include "pbd/xml++.h" #include "pbd/xml++.h"
#include "pbd/filesystem.h"
#include "ardour/filesystem_paths.h" #include "ardour/filesystem_paths.h"
#include "ardour/location.h" #include "ardour/location.h"
@ -90,7 +91,7 @@ class ExportProfileManager
ExportPresetPtr current_preset; ExportPresetPtr current_preset;
FileMap preset_file_map; FileMap preset_file_map;
std::vector<PBD::sys::path> find_file (std::string const & pattern); std::vector<std::string> find_file (std::string const & pattern);
PBD::sys::path export_config_dir; PBD::sys::path export_config_dir;
PBD::SearchPath search_path; PBD::SearchPath search_path;

View file

@ -20,7 +20,6 @@
#ifndef ARDOUR_FILESYSTEM_PATHS_INCLUDED #ifndef ARDOUR_FILESYSTEM_PATHS_INCLUDED
#define ARDOUR_FILESYSTEM_PATHS_INCLUDED #define ARDOUR_FILESYSTEM_PATHS_INCLUDED
#include "pbd/filesystem.h"
#include "pbd/search_path.h" #include "pbd/search_path.h"
namespace ARDOUR { namespace ARDOUR {
@ -29,13 +28,13 @@ namespace ARDOUR {
* @return the path to the directory used to store user specific ardour * @return the path to the directory used to store user specific ardour
* configuration files. * configuration files.
*/ */
PBD::sys::path user_config_directory (); std::string user_config_directory ();
/** /**
* @return the path to the directory that contains the system wide ardour * @return the path to the directory that contains the system wide ardour
* modules. * modules.
*/ */
PBD::sys::path ardour_dll_directory (); std::string ardour_dll_directory ();
/** /**
* @return the search path to be used when looking for per-system * @return the search path to be used when looking for per-system

View file

@ -22,8 +22,6 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "pbd/filesystem.h"
namespace ARDOUR { namespace ARDOUR {
class SessionDirectory class SessionDirectory
@ -33,7 +31,7 @@ public:
/** /**
* @param session_path An absolute path to a session directory. * @param session_path An absolute path to a session directory.
*/ */
SessionDirectory (const PBD::sys::path& session_path); SessionDirectory (const std::string& session_path);
/** /**
* Change the root path of this SessionDirectory object * Change the root path of this SessionDirectory object
@ -43,7 +41,7 @@ public:
/** /**
* @return the absolute path to the root directory of the session * @return the absolute path to the root directory of the session
*/ */
const PBD::sys::path root_path() const { return m_root_path; } const std::string root_path() const { return m_root_path; }
/** /**
* @return the absolute path to the directory in which * @return the absolute path to the directory in which
@ -54,40 +52,40 @@ public:
* directory otherwise it will return the new location * directory otherwise it will return the new location
* of root_path()/interchange/session_name/audiofiles * of root_path()/interchange/session_name/audiofiles
*/ */
const PBD::sys::path sound_path () const; const std::string sound_path () const;
/** /**
* @return the absolute path to the directory in which * @return the absolute path to the directory in which
* the session stores MIDI files, ie * the session stores MIDI files, ie
* root_path()/interchange/session_name/midifiles * root_path()/interchange/session_name/midifiles
*/ */
const PBD::sys::path midi_path () const; const std::string midi_path () const;
/** /**
* @return the absolute path to the directory in which * @return the absolute path to the directory in which
* the session stores MIDNAM patch files, ie * the session stores MIDNAM patch files, ie
* root_path()/interchange/session_name/patchfiles * root_path()/interchange/session_name/patchfiles
*/ */
const PBD::sys::path midi_patch_path () const; const std::string midi_patch_path () const;
/** /**
* @return The absolute path to the directory in which all * @return The absolute path to the directory in which all
* peak files are stored for a session. * peak files are stored for a session.
*/ */
const PBD::sys::path peak_path () const; const std::string peak_path () const;
/** /**
* @return The absolute path to the directory that source * @return The absolute path to the directory that source
* files are moved to when they are no longer part of the * files are moved to when they are no longer part of the
* session. * session.
*/ */
const PBD::sys::path dead_path () const; const std::string dead_path () const;
/** /**
* @return The absolute path to the directory that audio * @return The absolute path to the directory that audio
* files are created in by default when exporting. * files are created in by default when exporting.
*/ */
const PBD::sys::path export_path () const; const std::string export_path () const;
/** /**
* @return true if session directory and all the required * @return true if session directory and all the required
@ -98,9 +96,6 @@ public:
/** /**
* Create the session directory and all the subdirectories. * Create the session directory and all the subdirectories.
* *
* @throw PBD::sys::filesystem_error if the directories were
* not able to be created.
*
* @return true If a new session directory was created, otherwise * @return true If a new session directory was created, otherwise
* (if it already existed) false. * (if it already existed) false.
* *
@ -113,7 +108,7 @@ public:
* are created for different source types. * are created for different source types.
* i.e root_path()/interchange/session_name * i.e root_path()/interchange/session_name
*/ */
const PBD::sys::path sources_root() const; const std::string sources_root() const;
private: private:
@ -121,15 +116,15 @@ private:
* @return The path to the old style sound directory. * @return The path to the old style sound directory.
* It isn't created by create(). * It isn't created by create().
*/ */
const PBD::sys::path old_sound_path () const; const std::string old_sound_path () const;
/** /**
* @return a vector containing the fullpath of all subdirectories. * @return a vector containing the fullpath of all subdirectories.
*/ */
const std::vector<PBD::sys::path> sub_directories () const; const std::vector<std::string> sub_directories () const;
/// The path to the root of the session directory. /// The path to the root of the session directory.
PBD::sys::path m_root_path; std::string m_root_path;
}; };
} // namespace ARDOUR } // namespace ARDOUR

View file

@ -43,8 +43,8 @@ bool create_backup_file (const PBD::sys::path & file_path);
* @param directory_path The absolute path to a directory. * @param directory_path The absolute path to a directory.
* @param result vector to contain resulting state files. * @param result vector to contain resulting state files.
*/ */
void get_state_files_in_directory (const PBD::sys::path & directory_path, void get_state_files_in_directory (const std::string& directory_path,
std::vector<PBD::sys::path>& result); std::vector<std::string>& result);
/** /**
* Given a vector of paths to files, return a vector containing * Given a vector of paths to files, return a vector containing
@ -54,7 +54,7 @@ void get_state_files_in_directory (const PBD::sys::path & directory_path,
* @return a vector containing a list of file names without any * @return a vector containing a list of file names without any
* filename extension. * filename extension.
*/ */
std::vector<std::string> get_file_names_no_extension (const std::vector<PBD::sys::path> & file_paths); std::vector<std::string> get_file_names_no_extension (const std::vector<std::string> & file_paths);
} // namespace ARDOUR } // namespace ARDOUR

View file

@ -27,6 +27,7 @@
#include <glibmm/convert.h> #include <glibmm/convert.h>
#include "pbd/compose.h" #include "pbd/compose.h"
#include "pbd/filesystem.h"
#include "ardour/audio_library.h" #include "ardour/audio_library.h"
#include "ardour/utils.h" #include "ardour/utils.h"

View file

@ -212,7 +212,7 @@ AudioPlaylistSource::sample_rate () const
int int
AudioPlaylistSource::setup_peakfile () AudioPlaylistSource::setup_peakfile ()
{ {
_peak_path = Glib::build_filename (_session.session_directory().peak_path().to_string(), name() + ARDOUR::peakfile_suffix); _peak_path = Glib::build_filename (_session.session_directory().peak_path(), name() + ARDOUR::peakfile_suffix);
return initialize_peakfile (false, string()); return initialize_peakfile (false, string());
} }

View file

@ -22,6 +22,8 @@
#include <sstream> #include <sstream>
#include <glibmm/miscutils.h>
#include "pbd/failed_constructor.h" #include "pbd/failed_constructor.h"
#include "pbd/compose.h" #include "pbd/compose.h"
#include "pbd/error.h" #include "pbd/error.h"
@ -292,12 +294,8 @@ AudioRegionImporter::parse_source_xml ()
PBD::sys::path PBD::sys::path
AudioRegionImporter::get_sound_dir (XMLTree const & tree) AudioRegionImporter::get_sound_dir (XMLTree const & tree)
{ {
PBD::sys::path source_dir = tree.filename(); SessionDirectory session_dir(Glib::path_get_dirname (tree.filename()));
source_dir = source_dir.branch_path(); return session_dir.sound_path();
SessionDirectory session_dir(source_dir);
source_dir = session_dir.sound_path();
return source_dir;
} }
void void

View file

@ -52,7 +52,7 @@ watermark ()
void void
block_mothership () block_mothership ()
{ {
string hangup = Glib::build_filename (ARDOUR::user_config_directory().to_string(), OFF_THE_HOOK); string hangup = Glib::build_filename (ARDOUR::user_config_directory(), OFF_THE_HOOK);
int fd; int fd;
if ((fd = ::open (hangup.c_str(), O_RDWR|O_CREAT, 0600)) >= 0) { if ((fd = ::open (hangup.c_str(), O_RDWR|O_CREAT, 0600)) >= 0) {
close (fd); close (fd);
@ -62,14 +62,14 @@ block_mothership ()
void void
unblock_mothership () unblock_mothership ()
{ {
string hangup = Glib::build_filename (ARDOUR::user_config_directory().to_string(), OFF_THE_HOOK); string hangup = Glib::build_filename (ARDOUR::user_config_directory(), OFF_THE_HOOK);
::unlink (hangup.c_str()); ::unlink (hangup.c_str());
} }
bool bool
mothership_blocked () mothership_blocked ()
{ {
string hangup = Glib::build_filename (ARDOUR::user_config_directory().to_string(), OFF_THE_HOOK); string hangup = Glib::build_filename (ARDOUR::user_config_directory(), OFF_THE_HOOK);
return Glib::file_test (hangup, Glib::FILE_TEST_EXISTS); return Glib::file_test (hangup, Glib::FILE_TEST_EXISTS);
} }

View file

@ -197,7 +197,7 @@ ControlProtocolManager::load_mandatory_protocols ()
void void
ControlProtocolManager::discover_control_protocols () ControlProtocolManager::discover_control_protocols ()
{ {
vector<sys::path> cp_modules; vector<std::string> cp_modules;
Glib::PatternSpec so_extension_pattern("*.so"); Glib::PatternSpec so_extension_pattern("*.so");
Glib::PatternSpec dylib_extension_pattern("*.dylib"); Glib::PatternSpec dylib_extension_pattern("*.dylib");
@ -211,8 +211,8 @@ ControlProtocolManager::discover_control_protocols ()
DEBUG_TRACE (DEBUG::ControlProtocols, DEBUG_TRACE (DEBUG::ControlProtocols,
string_compose (_("looking for control protocols in %1\n"), control_protocol_search_path().to_string())); string_compose (_("looking for control protocols in %1\n"), control_protocol_search_path().to_string()));
for (vector<sys::path>::iterator i = cp_modules.begin(); i != cp_modules.end(); ++i) { for (vector<std::string>::iterator i = cp_modules.begin(); i != cp_modules.end(); ++i) {
control_protocol_discover ((*i).to_string()); control_protocol_discover (*i);
} }
} }

View file

@ -36,18 +36,11 @@ namespace ARDOUR {
SearchPath SearchPath
control_protocol_search_path () control_protocol_search_path ()
{ {
SearchPath spath (user_config_directory ()); SearchPath spath(user_config_directory ());
spath += ardour_dll_directory (); spath += ardour_dll_directory ();
spath.add_subdirectory_to_paths (surfaces_dir_name); spath.add_subdirectory_to_paths (surfaces_dir_name);
bool surfaces_path_defined = false; spath += SearchPath(Glib::getenv(surfaces_env_variable_name));
SearchPath spath_env (Glib::getenv(surfaces_env_variable_name, surfaces_path_defined));
if (surfaces_path_defined) {
spath += spath_env;
}
return spath; return spath;
} }

View file

@ -56,7 +56,7 @@ ExportFilename::ExportFilename (Session & session) :
std::time (&rawtime); std::time (&rawtime);
time_struct = localtime (&rawtime); time_struct = localtime (&rawtime);
folder = session.session_directory().export_path().to_string(); folder = session.session_directory().export_path();
XMLNode * instant_node = session.instant_xml ("ExportFilename"); XMLNode * instant_node = session.instant_xml ("ExportFilename");
if (instant_node) { if (instant_node) {
@ -102,7 +102,7 @@ ExportFilename::set_state (const XMLNode & node)
if ((prop = child->property ("relative"))) { if ((prop = child->property ("relative"))) {
if (!prop->value().compare ("true")) { if (!prop->value().compare ("true")) {
folder = session.session_directory().root_path().to_string(); folder = session.session_directory().root_path();
} }
} }
@ -345,7 +345,7 @@ ExportFilename::analyse_folder ()
{ {
FieldPair pair; FieldPair pair;
string session_dir = session.session_directory().root_path().to_string(); string session_dir = session.session_directory().root_path();
string::size_type session_dir_len = session_dir.length(); string::size_type session_dir_len = session_dir.length();
string folder_beginning = folder.substr (0, session_dir_len); string folder_beginning = folder.substr (0, session_dir_len);

View file

@ -36,17 +36,8 @@ SearchPath
export_formats_search_path () export_formats_search_path ()
{ {
SearchPath spath; SearchPath spath;
spath += Glib::build_filename (user_config_directory (), export_formats_dir_name);
spath = user_config_directory (); spath += SearchPath(Glib::getenv (export_env_variable_name));
spath.add_subdirectory_to_paths (export_formats_dir_name);
bool export_path_defined = false;
SearchPath spath_env = Glib::getenv (export_env_variable_name, export_path_defined);
if (export_path_defined) {
spath += spath_env;
}
return spath; return spath;
} }

View file

@ -26,6 +26,7 @@
#include "pbd/enumwriter.h" #include "pbd/enumwriter.h"
#include "pbd/xml++.h" #include "pbd/xml++.h"
#include "pbd/convert.h" #include "pbd/convert.h"
#include "pbd/filesystem.h"
#include "ardour/export_profile_manager.h" #include "ardour/export_profile_manager.h"
#include "ardour/export_format_specification.h" #include "ardour/export_format_specification.h"
@ -165,9 +166,9 @@ ExportProfileManager::load_preset (ExportPresetPtr preset)
void void
ExportProfileManager::load_presets () ExportProfileManager::load_presets ()
{ {
vector<sys::path> found = find_file (string_compose (X_("*%1"),export_preset_suffix)); vector<std::string> found = find_file (string_compose (X_("*%1"),export_preset_suffix));
for (vector<sys::path>::iterator it = found.begin(); it != found.end(); ++it) { for (vector<std::string>::iterator it = found.begin(); it != found.end(); ++it) {
load_preset_from_disk (*it); load_preset_from_disk (*it);
} }
} }
@ -300,10 +301,10 @@ ExportProfileManager::serialize_local_profile (XMLNode & root)
} }
} }
std::vector<sys::path> std::vector<std::string>
ExportProfileManager::find_file (std::string const & pattern) ExportProfileManager::find_file (std::string const & pattern)
{ {
vector<sys::path> found; vector<std::string> found;
Glib::PatternSpec pattern_spec (pattern); Glib::PatternSpec pattern_spec (pattern);
find_matching_files_in_search_path (search_path, pattern_spec, found); find_matching_files_in_search_path (search_path, pattern_spec, found);
@ -669,9 +670,9 @@ ExportProfileManager::serialize_format (FormatStatePtr state)
void void
ExportProfileManager::load_formats () ExportProfileManager::load_formats ()
{ {
vector<sys::path> found = find_file (string_compose ("*%1", export_format_suffix)); vector<std::string> found = find_file (string_compose ("*%1", export_format_suffix));
for (vector<sys::path>::iterator it = found.begin(); it != found.end(); ++it) { for (vector<std::string>::iterator it = found.begin(); it != found.end(); ++it) {
load_format_from_disk (*it); load_format_from_disk (*it);
} }
} }

View file

@ -22,6 +22,7 @@
#include "pbd/error.h" #include "pbd/error.h"
#include "pbd/compose.h" #include "pbd/compose.h"
#include "pbd/strsplit.h" #include "pbd/strsplit.h"
#include "pbd/filesystem.h"
#include <glibmm/miscutils.h> #include <glibmm/miscutils.h>
#include <glibmm/fileutils.h> #include <glibmm/fileutils.h>
@ -37,7 +38,7 @@ namespace ARDOUR {
using std::string; using std::string;
sys::path std::string
user_config_directory () user_config_directory ()
{ {
sys::path p; sys::path p;
@ -87,10 +88,10 @@ user_config_directory ()
exit (1); exit (1);
} }
return p; return p.to_string();
} }
sys::path std::string
ardour_dll_directory () ardour_dll_directory ()
{ {
std::string s = Glib::getenv("ARDOUR_DLL_PATH"); std::string s = Glib::getenv("ARDOUR_DLL_PATH");
@ -98,7 +99,7 @@ ardour_dll_directory ()
std::cerr << _("ARDOUR_DLL_PATH not set in environment - exiting\n"); std::cerr << _("ARDOUR_DLL_PATH not set in environment - exiting\n");
::exit (1); ::exit (1);
} }
return sys::path (s); return s;
} }
SearchPath SearchPath
@ -119,7 +120,7 @@ ardour_config_search_path ()
std::vector<string> ss; std::vector<string> ss;
split (s, ss, ':'); split (s, ss, ':');
for (std::vector<string>::iterator i = ss.begin(); i != ss.end(); ++i) { for (std::vector<string>::iterator i = ss.begin(); i != ss.end(); ++i) {
sp += sys::path (*i); sp += *i;
} }
search_path = sp; search_path = sp;
@ -147,7 +148,7 @@ ardour_data_search_path ()
std::vector<string> ss; std::vector<string> ss;
split (s, ss, ':'); split (s, ss, ':');
for (std::vector<string>::iterator i = ss.begin(); i != ss.end(); ++i) { for (std::vector<string>::iterator i = ss.begin(); i != ss.end(); ++i) {
sp += sys::path (*i); sp += *i;
} }
search_path = sp; search_path = sp;

View file

@ -56,6 +56,7 @@
#include "pbd/fpu.h" #include "pbd/fpu.h"
#include "pbd/file_utils.h" #include "pbd/file_utils.h"
#include "pbd/enumwriter.h" #include "pbd/enumwriter.h"
#include "pbd/filesystem.h"
#include "midi++/port.h" #include "midi++/port.h"
#include "midi++/manager.h" #include "midi++/manager.h"
@ -356,7 +357,7 @@ ARDOUR::cleanup ()
void void
ARDOUR::find_bindings_files (map<string,string>& files) ARDOUR::find_bindings_files (map<string,string>& files)
{ {
vector<sys::path> found; vector<std::string> found;
SearchPath spath = ardour_config_search_path(); SearchPath spath = ardour_config_search_path();
if (getenv ("ARDOUR_SAE")) { if (getenv ("ARDOUR_SAE")) {
@ -371,8 +372,8 @@ ARDOUR::find_bindings_files (map<string,string>& files)
return; return;
} }
for (vector<sys::path>::iterator x = found.begin(); x != found.end(); ++x) { for (vector<std::string>::iterator x = found.begin(); x != found.end(); ++x) {
sys::path path = *x; sys::path path(*x);
pair<string,string> namepath; pair<string,string> namepath;
namepath.second = path.to_string(); namepath.second = path.to_string();
namepath.first = path.leaf().substr (0, path.leaf().find_first_of ('.')); namepath.first = path.leaf().substr (0, path.leaf().find_first_of ('.'));
@ -453,7 +454,7 @@ ARDOUR::setup_fpu ()
string string
ARDOUR::translation_kill_path () ARDOUR::translation_kill_path ()
{ {
return Glib::build_filename (user_config_directory().to_string(), ".love_is_the_language_of_audio"); return Glib::build_filename (user_config_directory(), ".love_is_the_language_of_audio");
} }
bool bool

View file

@ -184,7 +184,7 @@ get_paths_for_new_sources (HeaderFormat hf, const bool allow_replacing, const st
const DataType type = SMFSource::safe_midi_file_extension (import_file_path) ? DataType::MIDI : DataType::AUDIO; const DataType type = SMFSource::safe_midi_file_extension (import_file_path) ? DataType::MIDI : DataType::AUDIO;
std::string filepath = (type == DataType::MIDI) std::string filepath = (type == DataType::MIDI)
? sdir.midi_path().to_string() : sdir.sound_path().to_string(); ? sdir.midi_path() : sdir.sound_path();
filepath = Glib::build_filename (filepath, filepath = Glib::build_filename (filepath,
get_non_existent_filename (hf, type, allow_replacing, filepath, basename, n, channels)); get_non_existent_filename (hf, type, allow_replacing, filepath, basename, n, channels));

View file

@ -20,6 +20,8 @@
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
#include <glibmm/fileutils.h>
#include "pbd/file_utils.h" #include "pbd/file_utils.h"
#include "pbd/error.h" #include "pbd/error.h"
@ -33,7 +35,6 @@ using namespace ARDOUR;
using namespace MIDI; using namespace MIDI;
using namespace MIDI::Name; using namespace MIDI::Name;
using namespace PBD; using namespace PBD;
using namespace PBD::sys;
MidiPatchManager* MidiPatchManager::_manager = 0; MidiPatchManager* MidiPatchManager::_manager = 0;
@ -56,23 +57,23 @@ MidiPatchManager::add_session_patches ()
return; return;
} }
path path_to_patches = _session->session_directory().midi_patch_path(); std::string path_to_patches = _session->session_directory().midi_patch_path();
if (!exists (path_to_patches)) { if (!Glib::file_test (path_to_patches, Glib::FILE_TEST_EXISTS)) {
return; return;
} }
assert(is_directory(path_to_patches)); assert (Glib::file_test (path_to_patches, Glib::FILE_TEST_IS_DIR));
Glib::PatternSpec pattern(string("*.midnam")); Glib::PatternSpec pattern(string("*.midnam"));
vector<path> result; vector<std::string> result;
find_matching_files_in_directory (path_to_patches, pattern, result); find_matching_files_in_directory (path_to_patches, pattern, result);
info << "Loading " << result.size() << " MIDI patches from " << path_to_patches.to_string() << endmsg; info << "Loading " << result.size() << " MIDI patches from " << path_to_patches << endmsg;
for (vector<path>::iterator i = result.begin(); i != result.end(); ++i) { for (vector<std::string>::iterator i = result.begin(); i != result.end(); ++i) {
boost::shared_ptr<MIDINameDocument> document(new MIDINameDocument(i->to_string())); boost::shared_ptr<MIDINameDocument> document(new MIDINameDocument(*i));
for (MIDINameDocument::MasterDeviceNamesList::const_iterator device = for (MIDINameDocument::MasterDeviceNamesList::const_iterator device =
document->master_device_names_by_model().begin(); document->master_device_names_by_model().begin();
device != document->master_device_names_by_model().end(); device != document->master_device_names_by_model().end();
@ -101,14 +102,14 @@ MidiPatchManager::refresh()
SearchPath search_path = midi_patch_search_path (); SearchPath search_path = midi_patch_search_path ();
Glib::PatternSpec pattern (string("*.midnam")); Glib::PatternSpec pattern (string("*.midnam"));
vector<path> result; vector<std::string> result;
find_matching_files_in_search_path (search_path, pattern, result); find_matching_files_in_search_path (search_path, pattern, result);
info << "Loading " << result.size() << " MIDI patches from " << search_path.to_string() << endmsg; info << "Loading " << result.size() << " MIDI patches from " << search_path.to_string() << endmsg;
for (vector<path>::iterator i = result.begin(); i != result.end(); ++i) { for (vector<std::string>::iterator i = result.begin(); i != result.end(); ++i) {
boost::shared_ptr<MIDINameDocument> document(new MIDINameDocument(i->to_string())); boost::shared_ptr<MIDINameDocument> document(new MIDINameDocument(*i));
for (MIDINameDocument::MasterDeviceNamesList::const_iterator device = for (MIDINameDocument::MasterDeviceNamesList::const_iterator device =
document->master_device_names_by_model().begin(); document->master_device_names_by_model().begin();
device != document->master_device_names_by_model().end(); device != document->master_device_names_by_model().end();

View file

@ -29,6 +29,7 @@
#include <algorithm> #include <algorithm>
#include <glibmm/fileutils.h> #include <glibmm/fileutils.h>
#include <glibmm/miscutils.h>
#include "pbd/xml++.h" #include "pbd/xml++.h"
#include "pbd/pthread_utils.h" #include "pbd/pthread_utils.h"
@ -339,8 +340,7 @@ MidiSource::clone (const string& path, Evoral::MusicalTime begin, Evoral::Musica
do { do {
newname = bump_name_once (newname, '-'); newname = bump_name_once (newname, '-');
/* XXX build path safely */ newpath = Glib::build_filename (_session.session_directory().midi_path(), newname + ".mid");
newpath = _session.session_directory().midi_path().to_string() +"/"+ newname + ".mid";
} while (Glib::file_test (newpath, Glib::FILE_TEST_EXISTS)); } while (Glib::file_test (newpath, Glib::FILE_TEST_EXISTS));
} else { } else {

View file

@ -62,7 +62,7 @@ PannerManager::instance ()
void void
PannerManager::discover_panners () PannerManager::discover_panners ()
{ {
vector<sys::path> panner_modules; vector<std::string> panner_modules;
Glib::PatternSpec so_extension_pattern("*.so"); Glib::PatternSpec so_extension_pattern("*.so");
Glib::PatternSpec dylib_extension_pattern("*.dylib"); Glib::PatternSpec dylib_extension_pattern("*.dylib");
@ -75,8 +75,8 @@ PannerManager::discover_panners ()
DEBUG_TRACE (DEBUG::Panning, string_compose (_("looking for panners in %1"), panner_search_path().to_string())); DEBUG_TRACE (DEBUG::Panning, string_compose (_("looking for panners in %1"), panner_search_path().to_string()));
for (vector<sys::path>::iterator i = panner_modules.begin(); i != panner_modules.end(); ++i) { for (vector<std::string>::iterator i = panner_modules.begin(); i != panner_modules.end(); ++i) {
panner_discover ((*i).to_string()); panner_discover (*i);
} }
} }
int int

View file

@ -34,18 +34,11 @@ namespace ARDOUR {
SearchPath SearchPath
panner_search_path () panner_search_path ()
{ {
SearchPath spath (user_config_directory ()); SearchPath spath(user_config_directory ());
spath += ardour_dll_directory (); spath += ardour_dll_directory ();
spath.add_subdirectory_to_paths(panner_dir_name); spath.add_subdirectory_to_paths(panner_dir_name);
bool panner_path_defined = false; spath += SearchPath(Glib::getenv(panner_env_variable_name));
SearchPath spath_env (Glib::getenv(panner_env_variable_name, panner_path_defined));
if (panner_path_defined) {
spath += spath_env;
}
return spath; return spath;
} }

View file

@ -46,6 +46,7 @@
#include "pbd/pathscanner.h" #include "pbd/pathscanner.h"
#include "pbd/whitespace.h" #include "pbd/whitespace.h"
#include "pbd/filesystem.h"
#include "ardour/debug.h" #include "ardour/debug.h"
#include "ardour/filesystem_paths.h" #include "ardour/filesystem_paths.h"

View file

@ -77,13 +77,12 @@ RCConfiguration::~RCConfiguration ()
int int
RCConfiguration::load_state () RCConfiguration::load_state ()
{ {
sys::path system_rc_file; std::string rcfile;
struct stat statbuf; struct stat statbuf;
/* load system configuration first */ /* load system configuration first */
if (find_file_in_search_path (ardour_config_search_path(), "ardour_system.rc", system_rc_file)) { if (find_file_in_search_path (ardour_config_search_path(), "ardour_system.rc", rcfile)) {
string rcfile = system_rc_file.to_string();
/* stupid XML Parser hates empty files */ /* stupid XML Parser hates empty files */
@ -111,10 +110,7 @@ RCConfiguration::load_state ()
/* now load configuration file for user */ /* now load configuration file for user */
sys::path user_rc_file; if (find_file_in_search_path (ardour_config_search_path(), "ardour.rc", rcfile)) {
if (find_file_in_search_path (ardour_config_search_path(), "ardour.rc", user_rc_file)) {
string rcfile = user_rc_file.to_string();
/* stupid XML parser hates empty files */ /* stupid XML parser hates empty files */

View file

@ -23,6 +23,7 @@
#include <algorithm> #include <algorithm>
#include "pbd/error.h" #include "pbd/error.h"
#include "pbd/filesystem.h"
#include "ardour/rc_configuration.h" #include "ardour/rc_configuration.h"
#include "ardour/filesystem_paths.h" #include "ardour/filesystem_paths.h"

View file

@ -47,6 +47,7 @@
#include "pbd/strsplit.h" #include "pbd/strsplit.h"
#include "pbd/strsplit.h" #include "pbd/strsplit.h"
#include "pbd/unwind.h" #include "pbd/unwind.h"
#include "pbd/filesystem.h"
#include "ardour/amp.h" #include "ardour/amp.h"
#include "ardour/analyser.h" #include "ardour/analyser.h"
@ -3199,7 +3200,7 @@ Session::new_source_path_from_name (DataType type, const string& name)
SessionDirectory sdir(get_best_session_directory_for_new_source()); SessionDirectory sdir(get_best_session_directory_for_new_source());
sys::path p; std::string p;
if (type == DataType::AUDIO) { if (type == DataType::AUDIO) {
p = sdir.sound_path(); p = sdir.sound_path();
} else if (type == DataType::MIDI) { } else if (type == DataType::MIDI) {
@ -3209,16 +3210,13 @@ Session::new_source_path_from_name (DataType type, const string& name)
return ""; return "";
} }
p /= name; return Glib::build_filename (p, name);
return p.to_string();
} }
string string
Session::peak_path (string base) const Session::peak_path (string base) const
{ {
sys::path peakfile_path(_session_dir->peak_path()); return Glib::build_filename (_session_dir->peak_path(), base + peakfile_suffix);
peakfile_path /= base + peakfile_suffix;
return peakfile_path.to_string();
} }
/** Return a unique name based on \a base for a new internal audio source */ /** Return a unique name based on \a base for a new internal audio source */
@ -3282,7 +3280,7 @@ Session::new_audio_source_name (const string& base, uint32_t nchan, uint32_t cha
SessionDirectory sdir((*i).path); SessionDirectory sdir((*i).path);
string spath = sdir.sound_path().to_string(); string spath = sdir.sound_path();
/* note that we search *without* the extension so that /* note that we search *without* the extension so that
we don't end up both "Audio 1-1.wav" and "Audio 1-1.caf" we don't end up both "Audio 1-1.wav" and "Audio 1-1.caf"
@ -3955,7 +3953,7 @@ Session::write_one_track (AudioTrack& track, framepos_t start, framepos_t end,
framepos_t to_do; framepos_t to_do;
BufferSet buffers; BufferSet buffers;
SessionDirectory sdir(get_best_session_directory_for_new_source ()); SessionDirectory sdir(get_best_session_directory_for_new_source ());
const string sound_dir = sdir.sound_path().to_string(); const string sound_dir = sdir.sound_path();
framepos_t len = end - start; framepos_t len = end - start;
bool need_block_size_reset = false; bool need_block_size_reset = false;
string ext; string ext;
@ -4441,10 +4439,10 @@ Session::source_search_path (DataType type) const
if (session_dirs.size() == 1) { if (session_dirs.size() == 1) {
switch (type) { switch (type) {
case DataType::AUDIO: case DataType::AUDIO:
s.push_back ( _session_dir->sound_path().to_string()); s.push_back ( _session_dir->sound_path());
break; break;
case DataType::MIDI: case DataType::MIDI:
s.push_back (_session_dir->midi_path().to_string()); s.push_back (_session_dir->midi_path());
break; break;
} }
} else { } else {
@ -4452,10 +4450,10 @@ Session::source_search_path (DataType type) const
SessionDirectory sdir (i->path); SessionDirectory sdir (i->path);
switch (type) { switch (type) {
case DataType::AUDIO: case DataType::AUDIO:
s.push_back (sdir.sound_path().to_string()); s.push_back (sdir.sound_path());
break; break;
case DataType::MIDI: case DataType::MIDI:
s.push_back (sdir.midi_path().to_string()); s.push_back (sdir.midi_path());
break; break;
} }
} }

View file

@ -16,6 +16,9 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include <glibmm/fileutils.h>
#include <glibmm/miscutils.h>
#include "pbd/error.h" #include "pbd/error.h"
#include "pbd/compose.h" #include "pbd/compose.h"
#include "pbd/filesystem.h" #include "pbd/filesystem.h"
@ -31,7 +34,7 @@ namespace ARDOUR {
using namespace std; using namespace std;
using namespace PBD::sys; using namespace PBD::sys;
SessionDirectory::SessionDirectory (const path& session_path) SessionDirectory::SessionDirectory (const std::string& session_path)
: m_root_path(session_path) : m_root_path(session_path)
{ {
@ -49,20 +52,16 @@ SessionDirectory::create ()
{ {
bool is_new = false; bool is_new = false;
vector<path> sub_dirs = sub_directories (); vector<std::string> sub_dirs = sub_directories ();
for (vector<path>::const_iterator i = sub_dirs.begin(); i != sub_dirs.end(); ++i) for (vector<std::string>::const_iterator i = sub_dirs.begin(); i != sub_dirs.end(); ++i)
{ {
try if (Glib::file_test (*i, Glib::FILE_TEST_EXISTS)) {
{ is_new = false;
if(create_directories(*i)) is_new = true;
} }
catch (PBD::sys::filesystem_error& ex)
{
// log the error
PBD::error << string_compose(_("Cannot create Session directory at path %1 Error: %2"), (*i).to_string(), ex.what()) << endmsg;
// and rethrow if (g_mkdir_with_parents (i->c_str(), 0755) != 0) {
throw ex; PBD::error << string_compose(_("Cannot create Session directory at path %1 Error: %2"), *i, g_strerror(errno)) << endmsg;
} }
} }
@ -72,28 +71,29 @@ SessionDirectory::create ()
bool bool
SessionDirectory::is_valid () const SessionDirectory::is_valid () const
{ {
if (!is_directory (m_root_path)) return false; if (!Glib::file_test (m_root_path, Glib::FILE_TEST_IS_DIR)) return false;
vector<path> sub_dirs = sub_directories (); vector<std::string> sub_dirs = sub_directories ();
for (vector<path>::iterator i = sub_dirs.begin(); i != sub_dirs.end(); ++i) { for (vector<std::string>::iterator i = sub_dirs.begin(); i != sub_dirs.end(); ++i) {
if (!is_directory (*i)) { if (!Glib::file_test (*i, Glib::FILE_TEST_IS_DIR)) {
PBD::warning << string_compose(_("Session subdirectory does not exist at path %1"), (*i).to_string()) << endmsg; PBD::warning << string_compose(_("Session subdirectory does not exist at path %1"), *i) << endmsg;
return false; return false;
} }
} }
return true; return true;
} }
const path const std::string
SessionDirectory::old_sound_path () const SessionDirectory::old_sound_path () const
{ {
return m_root_path / old_sound_dir_name; return Glib::build_filename (m_root_path, old_sound_dir_name);
} }
const path const std::string
SessionDirectory::sources_root () const SessionDirectory::sources_root () const
{ {
// fix this later
path p = m_root_path; path p = m_root_path;
if (p.leaf() == ".") { if (p.leaf() == ".") {
@ -102,52 +102,53 @@ SessionDirectory::sources_root () const
const string legalized_root (legalize_for_path (p.leaf ())); const string legalized_root (legalize_for_path (p.leaf ()));
return m_root_path / interchange_dir_name / legalized_root; path sources_root_path = m_root_path / interchange_dir_name / legalized_root;
return sources_root_path.to_string ();
} }
const path const std::string
SessionDirectory::sound_path () const SessionDirectory::sound_path () const
{ {
if(is_directory (old_sound_path ())) return old_sound_path(); if (Glib::file_test (old_sound_path (), Glib::FILE_TEST_IS_DIR)) return old_sound_path();
// the new style sound directory // the new style sound directory
return sources_root() / sound_dir_name; return Glib::build_filename (sources_root(), sound_dir_name);
} }
const path const std::string
SessionDirectory::midi_path () const SessionDirectory::midi_path () const
{ {
return sources_root() / midi_dir_name; return Glib::build_filename (sources_root(), midi_dir_name);
} }
const path const std::string
SessionDirectory::midi_patch_path () const SessionDirectory::midi_patch_path () const
{ {
return sources_root() / midi_patch_dir_name; return Glib::build_filename (sources_root(), midi_patch_dir_name);
} }
const path const std::string
SessionDirectory::peak_path () const SessionDirectory::peak_path () const
{ {
return m_root_path / peak_dir_name; return Glib::build_filename (m_root_path, peak_dir_name);
} }
const path const std::string
SessionDirectory::dead_path () const SessionDirectory::dead_path () const
{ {
return m_root_path / dead_dir_name; return Glib::build_filename (m_root_path, dead_dir_name);
} }
const path const std::string
SessionDirectory::export_path () const SessionDirectory::export_path () const
{ {
return m_root_path / export_dir_name; return Glib::build_filename (m_root_path, export_dir_name);
} }
const vector<path> const vector<std::string>
SessionDirectory::sub_directories () const SessionDirectory::sub_directories () const
{ {
vector<path> tmp_paths; vector<std::string> tmp_paths;
tmp_paths.push_back (sound_path ()); tmp_paths.push_back (sound_path ());
tmp_paths.push_back (midi_path ()); tmp_paths.push_back (midi_path ());

View file

@ -288,7 +288,7 @@ Session::first_stage_init (string fullpath, string snapshot_name)
int int
Session::second_stage_init () Session::second_stage_init ()
{ {
AudioFileSource::set_peak_dir (_session_dir->peak_path().to_string()); AudioFileSource::set_peak_dir (_session_dir->peak_path());
if (!_is_new) { if (!_is_new) {
if (load_state (_current_snapshot_name)) { if (load_state (_current_snapshot_name)) {
@ -392,7 +392,7 @@ Session::raid_path () const
SearchPath raid_search_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) {
raid_search_path += sys::path((*i).path); raid_search_path += (*i).path;
} }
return raid_search_path.to_string (); return raid_search_path.to_string ();
@ -415,7 +415,7 @@ Session::setup_raid_path (string path)
SearchPath midi_search_path; SearchPath midi_search_path;
for (SearchPath::const_iterator i = search_path.begin(); i != search_path.end(); ++i) { for (SearchPath::const_iterator i = search_path.begin(); i != search_path.end(); ++i) {
sp.path = (*i).to_string (); sp.path = *i;
sp.blocks = 0; // not needed sp.blocks = 0; // not needed
session_dirs.push_back (sp); session_dirs.push_back (sp);
@ -445,35 +445,35 @@ Session::ensure_subdirs ()
{ {
string dir; string dir;
dir = session_directory().peak_path().to_string(); dir = session_directory().peak_path();
if (g_mkdir_with_parents (dir.c_str(), 0755) < 0) { if (g_mkdir_with_parents (dir.c_str(), 0755) < 0) {
error << string_compose(_("Session: cannot create session peakfile folder \"%1\" (%2)"), dir, strerror (errno)) << endmsg; error << string_compose(_("Session: cannot create session peakfile folder \"%1\" (%2)"), dir, strerror (errno)) << endmsg;
return -1; return -1;
} }
dir = session_directory().sound_path().to_string(); dir = session_directory().sound_path();
if (g_mkdir_with_parents (dir.c_str(), 0755) < 0) { if (g_mkdir_with_parents (dir.c_str(), 0755) < 0) {
error << string_compose(_("Session: cannot create session sounds dir \"%1\" (%2)"), dir, strerror (errno)) << endmsg; error << string_compose(_("Session: cannot create session sounds dir \"%1\" (%2)"), dir, strerror (errno)) << endmsg;
return -1; return -1;
} }
dir = session_directory().midi_path().to_string(); dir = session_directory().midi_path();
if (g_mkdir_with_parents (dir.c_str(), 0755) < 0) { if (g_mkdir_with_parents (dir.c_str(), 0755) < 0) {
error << string_compose(_("Session: cannot create session midi dir \"%1\" (%2)"), dir, strerror (errno)) << endmsg; error << string_compose(_("Session: cannot create session midi dir \"%1\" (%2)"), dir, strerror (errno)) << endmsg;
return -1; return -1;
} }
dir = session_directory().dead_path().to_string(); dir = session_directory().dead_path();
if (g_mkdir_with_parents (dir.c_str(), 0755) < 0) { if (g_mkdir_with_parents (dir.c_str(), 0755) < 0) {
error << string_compose(_("Session: cannot create session dead sounds folder \"%1\" (%2)"), dir, strerror (errno)) << endmsg; error << string_compose(_("Session: cannot create session dead sounds folder \"%1\" (%2)"), dir, strerror (errno)) << endmsg;
return -1; return -1;
} }
dir = session_directory().export_path().to_string(); dir = session_directory().export_path();
if (g_mkdir_with_parents (dir.c_str(), 0755) < 0) { if (g_mkdir_with_parents (dir.c_str(), 0755) < 0) {
error << string_compose(_("Session: cannot create session export folder \"%1\" (%2)"), dir, strerror (errno)) << endmsg; error << string_compose(_("Session: cannot create session export folder \"%1\" (%2)"), dir, strerror (errno)) << endmsg;
@ -656,8 +656,8 @@ Session::rename_state (string old_name, string new_name)
const string old_xml_filename = legalize_for_path (old_name) + statefile_suffix; const string old_xml_filename = legalize_for_path (old_name) + statefile_suffix;
const string new_xml_filename = legalize_for_path (new_name) + statefile_suffix; const string new_xml_filename = legalize_for_path (new_name) + statefile_suffix;
const sys::path old_xml_path = _session_dir->root_path() / old_xml_filename; const sys::path old_xml_path(Glib::build_filename (_session_dir->root_path(), old_xml_filename));
const sys::path new_xml_path = _session_dir->root_path() / new_xml_filename; const sys::path new_xml_path(Glib::build_filename (_session_dir->root_path(), new_xml_filename));
try try
{ {
@ -1226,7 +1226,7 @@ Session::set_state (const XMLNode& node, int version)
} }
} }
setup_raid_path(_session_dir->root_path().to_string()); setup_raid_path(_session_dir->root_path());
if ((prop = node.property (X_("id-counter"))) != 0) { if ((prop = node.property (X_("id-counter"))) != 0) {
uint64_t x; uint64_t x;
@ -2134,7 +2134,7 @@ string
Session::get_best_session_directory_for_new_source () Session::get_best_session_directory_for_new_source ()
{ {
vector<space_and_path>::iterator i; vector<space_and_path>::iterator i;
string result = _session_dir->root_path().to_string(); string result = _session_dir->root_path();
/* handle common case without system calls */ /* handle common case without system calls */
@ -2750,7 +2750,7 @@ Session::cleanup_sources (CleanupReport& rep)
++nexti; ++nexti;
SessionDirectory sdir ((*i).path); SessionDirectory sdir ((*i).path);
audio_path += sdir.sound_path().to_string(); audio_path += sdir.sound_path();
if (nexti != session_dirs.end()) { if (nexti != session_dirs.end()) {
audio_path += ':'; audio_path += ':';
@ -2768,7 +2768,7 @@ Session::cleanup_sources (CleanupReport& rep)
++nexti; ++nexti;
SessionDirectory sdir ((*i).path); SessionDirectory sdir ((*i).path);
midi_path += sdir.midi_path().to_string(); midi_path += sdir.midi_path();
if (nexti != session_dirs.end()) { if (nexti != session_dirs.end()) {
midi_path += ':'; midi_path += ':';
@ -3252,8 +3252,8 @@ Session::save_history (string snapshot_name)
const string history_filename = legalize_for_path (snapshot_name) + history_suffix; const string history_filename = legalize_for_path (snapshot_name) + history_suffix;
const string backup_filename = history_filename + backup_suffix; const string backup_filename = history_filename + backup_suffix;
const sys::path xml_path = _session_dir->root_path() / history_filename; const sys::path xml_path(Glib::build_filename (_session_dir->root_path(), history_filename));
const sys::path backup_path = _session_dir->root_path() / backup_filename; const sys::path backup_path(Glib::build_filename (_session_dir->root_path(), backup_filename));
if (sys::exists (xml_path)) { if (sys::exists (xml_path)) {
try try
@ -3304,7 +3304,7 @@ Session::restore_history (string snapshot_name)
} }
const string xml_filename = legalize_for_path (snapshot_name) + history_suffix; const string xml_filename = legalize_for_path (snapshot_name) + history_suffix;
const sys::path xml_path = _session_dir->root_path() / xml_filename; const sys::path xml_path(Glib::build_filename (_session_dir->root_path(), xml_filename));
info << "Loading history from " << xml_path.to_string() << endmsg; info << "Loading history from " << xml_path.to_string() << endmsg;
@ -3681,7 +3681,7 @@ Session::rename (const std::string& new_name)
string newstr; string newstr;
bool first = true; bool first = true;
string const old_sources_root = _session_dir->sources_root().to_string (); string const old_sources_root = _session_dir->sources_root();
#define RENAME ::rename #define RENAME ::rename
@ -3810,7 +3810,7 @@ Session::rename (const std::string& new_name)
boost::shared_ptr<FileSource> fs = boost::dynamic_pointer_cast<FileSource> (i->second); boost::shared_ptr<FileSource> fs = boost::dynamic_pointer_cast<FileSource> (i->second);
if (fs) { if (fs) {
string p = fs->path (); string p = fs->path ();
boost::replace_all (p, old_sources_root, _session_dir->sources_root().to_string ()); boost::replace_all (p, old_sources_root, _session_dir->sources_root());
fs->set_path (p); fs->set_path (p);
} }
} }

View file

@ -54,8 +54,8 @@ create_backup_file (const sys::path & file_path)
} }
void void
get_state_files_in_directory (const sys::path & directory_path, get_state_files_in_directory (const std::string & directory_path,
vector<sys::path> & result) vector<std::string> & result)
{ {
Glib::PatternSpec state_file_pattern('*' + string(statefile_suffix)); Glib::PatternSpec state_file_pattern('*' + string(statefile_suffix));
@ -64,7 +64,7 @@ get_state_files_in_directory (const sys::path & directory_path,
} }
vector<string> vector<string>
get_file_names_no_extension (const vector<sys::path> & file_paths) get_file_names_no_extension (const vector<std::string> & file_paths)
{ {
vector<string> result; vector<string> result;

View file

@ -15,26 +15,7 @@ bool
create_session_directory (const string& session_directory_path) create_session_directory (const string& session_directory_path)
{ {
SessionDirectory sdir(session_directory_path); SessionDirectory sdir(session_directory_path);
sdir.create();
try
{
// create all the required session directories
sdir.create();
}
catch(sys::filesystem_error& ex)
{
// log the exception
warning << string_compose
(
_("Unable to create session directory at path %1 : %2"),
session_directory_path,
ex.what()
);
return false;
}
// successfully created the session directory
return true; return true;
} }

View file

@ -19,6 +19,7 @@
#include "pbd/locale_guard.h" #include "pbd/locale_guard.h"
#include "pbd/pathscanner.h" #include "pbd/pathscanner.h"
#include "pbd/filesystem.h"
#include "ardour/vst_plugin.h" #include "ardour/vst_plugin.h"
#include "ardour/vestige/aeffectx.h" #include "ardour/vestige/aeffectx.h"
#include "ardour/session.h" #include "ardour/session.h"

View file

@ -20,6 +20,7 @@
#include <algorithm> #include <algorithm>
#include <glibmm/fileutils.h> #include <glibmm/fileutils.h>
#include <glibmm/miscutils.h>
#include <glibmm/pattern.h> #include <glibmm/pattern.h>
#include "pbd/compose.h" #include "pbd/compose.h"
@ -32,13 +33,13 @@ using namespace std;
namespace PBD { namespace PBD {
void void
get_files_in_directory (const sys::path& directory_path, vector<string>& result) get_files_in_directory (const std::string& directory_path, vector<string>& result)
{ {
if (!is_directory(directory_path)) return; if (!Glib::file_test (directory_path, Glib::FILE_TEST_IS_DIR)) return;
try try
{ {
Glib::Dir dir(directory_path.to_string()); Glib::Dir dir(directory_path);
std::copy(dir.begin(), dir.end(), std::back_inserter(result)); std::copy(dir.begin(), dir.end(), std::back_inserter(result));
} }
catch (Glib::FileError& err) catch (Glib::FileError& err)
@ -48,9 +49,9 @@ get_files_in_directory (const sys::path& directory_path, vector<string>& result)
} }
void void
find_matching_files_in_directory (const sys::path& directory, find_matching_files_in_directory (const std::string& directory,
const Glib::PatternSpec& pattern, const Glib::PatternSpec& pattern,
vector<sys::path>& result) vector<std::string>& result)
{ {
vector<string> tmp_files; vector<string> tmp_files;
@ -63,19 +64,19 @@ find_matching_files_in_directory (const sys::path& directory,
{ {
if (!pattern.match(*file_iter)) continue; if (!pattern.match(*file_iter)) continue;
sys::path full_path(directory); std::string full_path(directory);
full_path /= *file_iter; full_path = Glib::build_filename (full_path, *file_iter);
result.push_back(full_path); result.push_back(full_path);
} }
} }
void void
find_matching_files_in_directories (const vector<sys::path>& paths, find_matching_files_in_directories (const vector<std::string>& paths,
const Glib::PatternSpec& pattern, const Glib::PatternSpec& pattern,
vector<sys::path>& result) vector<std::string>& result)
{ {
for (vector<sys::path>::const_iterator path_iter = paths.begin(); for (vector<std::string>::const_iterator path_iter = paths.begin();
path_iter != paths.end(); path_iter != paths.end();
++path_iter) ++path_iter)
{ {
@ -86,7 +87,7 @@ find_matching_files_in_directories (const vector<sys::path>& paths,
void void
find_matching_files_in_search_path (const SearchPath& search_path, find_matching_files_in_search_path (const SearchPath& search_path,
const Glib::PatternSpec& pattern, const Glib::PatternSpec& pattern,
vector<sys::path>& result) vector<std::string>& result)
{ {
find_matching_files_in_directories (search_path, pattern, result); find_matching_files_in_directories (search_path, pattern, result);
} }
@ -94,9 +95,9 @@ find_matching_files_in_search_path (const SearchPath& search_path,
bool bool
find_file_in_search_path(const SearchPath& search_path, find_file_in_search_path(const SearchPath& search_path,
const string& filename, const string& filename,
sys::path& result) std::string& result)
{ {
vector<sys::path> tmp; vector<std::string> tmp;
Glib::PatternSpec tmp_pattern(filename); Glib::PatternSpec tmp_pattern(filename);
find_matching_files_in_search_path (search_path, tmp_pattern, tmp); find_matching_files_in_search_path (search_path, tmp_pattern, tmp);
@ -113,7 +114,7 @@ find_file_in_search_path(const SearchPath& search_path,
( (
"Found more than one file matching %1 in search path %2", "Found more than one file matching %1 in search path %2",
filename, filename,
search_path.to_string () search_path ()
) )
<< endmsg; << endmsg;
} }

View file

@ -38,7 +38,7 @@ namespace PBD {
* @param result A vector of filenames. * @param result A vector of filenames.
*/ */
void void
get_files_in_directory (const sys::path& path, get_files_in_directory (const std::string& path,
std::vector<std::string>& result); std::vector<std::string>& result);
/** /**
@ -50,9 +50,9 @@ get_files_in_directory (const sys::path& path,
* @param result A vector in which to place the resulting matches. * @param result A vector in which to place the resulting matches.
*/ */
void void
find_matching_files_in_directory (const sys::path& directory, find_matching_files_in_directory (const std::string& directory,
const Glib::PatternSpec& pattern, const Glib::PatternSpec& pattern,
std::vector<sys::path>& result); std::vector<std::string>& result);
/** /**
* Takes a number of directory paths and returns all the files matching * Takes a number of directory paths and returns all the files matching
@ -63,9 +63,9 @@ find_matching_files_in_directory (const sys::path& directory,
* @param result A vector in which to place the resulting matches. * @param result A vector in which to place the resulting matches.
*/ */
void void
find_matching_files_in_directories (const std::vector<sys::path>& directory_paths, find_matching_files_in_directories (const std::vector<std::string>& directory_paths,
const Glib::PatternSpec& pattern, const Glib::PatternSpec& pattern,
std::vector<sys::path>& result); std::vector<std::string>& result);
/** /**
* Takes a SearchPath and puts a list of all the files in the search path * Takes a SearchPath and puts a list of all the files in the search path
@ -78,7 +78,7 @@ find_matching_files_in_directories (const std::vector<sys::path>& directory_path
void void
find_matching_files_in_search_path (const SearchPath& search_path, find_matching_files_in_search_path (const SearchPath& search_path,
const Glib::PatternSpec& pattern, const Glib::PatternSpec& pattern,
std::vector<sys::path>& result); std::vector<std::string>& result);
/** /**
* Takes a search path and a file name and place the full path * Takes a search path and a file name and place the full path
@ -89,7 +89,7 @@ find_matching_files_in_search_path (const SearchPath& search_path,
bool bool
find_file_in_search_path (const SearchPath& search_path, find_file_in_search_path (const SearchPath& search_path,
const std::string& filename, const std::string& filename,
sys::path& result); std::string& result);
} // namespace PBD } // namespace PBD

View file

@ -23,8 +23,6 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "pbd/filesystem.h"
namespace PBD { namespace PBD {
/** /**
@ -36,7 +34,7 @@ namespace PBD {
* The SearchPath class does not test whether the paths exist * The SearchPath class does not test whether the paths exist
* or are directories. It is basically just a container. * or are directories. It is basically just a container.
*/ */
class SearchPath : public std::vector<sys::path> class SearchPath : public std::vector<std::string>
{ {
public: public:
/** /**
@ -57,20 +55,13 @@ public:
*/ */
SearchPath (const std::string& search_path); SearchPath (const std::string& search_path);
/**
* Initialize SearchPath from a sys::path.
*
* @param directory_path A directory path.
*/
SearchPath (const PBD::sys::path& directory_path);
/** /**
* Initialize SearchPath from a vector of paths that may or may * Initialize SearchPath from a vector of paths that may or may
* not exist. * not exist.
* *
* @param paths A vector of paths. * @param paths A vector of paths.
*/ */
SearchPath (const std::vector<PBD::sys::path>& paths); SearchPath (const std::vector<std::string>& paths);
/** /**
* @return a search path string. * @return a search path string.
@ -88,7 +79,7 @@ public:
/** /**
* Add another directory path to the search path. * Add another directory path to the search path.
*/ */
SearchPath& operator+= (const PBD::sys::path& directory_path); SearchPath& operator+= (const std::string& directory_path);
/** /**
* Concatenate another SearchPath onto this. * Concatenate another SearchPath onto this.
@ -98,7 +89,7 @@ public:
/** /**
* Add another path to the search path. * Add another path to the search path.
*/ */
SearchPath& operator+ (const PBD::sys::path& directory_path); SearchPath& operator+ (const std::string& directory_path);
/** /**
* Add a sub-directory to each path in the search path. * Add a sub-directory to each path in the search path.
@ -108,8 +99,9 @@ public:
SearchPath& add_subdirectory_to_paths (const std::string& subdir); SearchPath& add_subdirectory_to_paths (const std::string& subdir);
protected: protected:
void add_directory (const sys::path& directory_path);
void add_directories (const std::vector<PBD::sys::path>& paths); void add_directory (const std::string& directory_path);
void add_directories (const std::vector<std::string>& paths);
}; };
} // namespace PBD } // namespace PBD

View file

@ -17,6 +17,8 @@
*/ */
#include <glibmm/miscutils.h>
#include "pbd/tokenizer.h" #include "pbd/tokenizer.h"
#include "pbd/search_path.h" #include "pbd/search_path.h"
#include "pbd/error.h" #include "pbd/error.h"
@ -42,34 +44,30 @@ SearchPath::SearchPath ()
SearchPath::SearchPath (const string& path) SearchPath::SearchPath (const string& path)
{ {
vector<sys::path> tmp; vector<std::string> tmp;
if (tokenize (path, string(path_delimiter), std::back_inserter (tmp))) { if (tokenize (path, string(path_delimiter), std::back_inserter (tmp))) {
add_directories (tmp); add_directories (tmp);
} }
} }
SearchPath::SearchPath (const sys::path& directory_path) SearchPath::SearchPath (const vector<std::string>& paths)
{
add_directory (directory_path);
}
SearchPath::SearchPath (const vector<sys::path>& paths)
{ {
add_directories (paths); add_directories (paths);
} }
void void
SearchPath::add_directory (const sys::path& directory_path) SearchPath::add_directory (const std::string& directory_path)
{ {
// test for existance and warn etc? if (!directory_path.empty()) {
push_back(directory_path); push_back(directory_path);
}
} }
void void
SearchPath::add_directories (const vector<sys::path>& paths) SearchPath::add_directories (const vector<std::string>& paths)
{ {
for(vector<sys::path>::const_iterator i = paths.begin(); i != paths.end(); ++i) { for(vector<std::string>::const_iterator i = paths.begin(); i != paths.end(); ++i) {
add_directory (*i); add_directory (*i);
} }
} }
@ -79,8 +77,8 @@ SearchPath::to_string () const
{ {
string path; string path;
for (vector<sys::path>::const_iterator i = begin(); i != end(); ++i) { for (vector<std::string>::const_iterator i = begin(); i != end(); ++i) {
path += (*i).to_string(); path += *i;
path += path_delimiter; path += path_delimiter;
} }
@ -97,14 +95,14 @@ SearchPath::operator+= (const SearchPath& spath)
} }
SearchPath& SearchPath&
SearchPath::operator+= (const sys::path& directory_path) SearchPath::operator+= (const std::string& directory_path)
{ {
add_directory (directory_path); add_directory (directory_path);
return *this; return *this;
} }
SearchPath& SearchPath&
SearchPath::operator+ (const sys::path& directory_path) SearchPath::operator+ (const std::string& directory_path)
{ {
add_directory (directory_path); add_directory (directory_path);
return *this; return *this;
@ -121,10 +119,10 @@ SearchPath::operator+ (const SearchPath& spath)
SearchPath& SearchPath&
SearchPath::add_subdirectory_to_paths (const string& subdir) SearchPath::add_subdirectory_to_paths (const string& subdir)
{ {
for (vector<sys::path>::iterator i = begin(); i != end(); ++i) { for (vector<std::string>::iterator i = begin(); i != end(); ++i) {
// should these new paths just be added to the end of // should these new paths just be added to the end of
// the search path rather than replace? // the search path rather than replace?
*i /= subdir; *i = Glib::build_filename (*i, subdir);
} }
return *this; return *this;

View file

@ -29,6 +29,7 @@
#include "pbd/failed_constructor.h" #include "pbd/failed_constructor.h"
#include "pbd/pathscanner.h" #include "pbd/pathscanner.h"
#include "pbd/xml++.h" #include "pbd/xml++.h"
#include "pbd/filesystem.h"
#include "midi++/port.h" #include "midi++/port.h"
#include "midi++/manager.h" #include "midi++/manager.h"
@ -147,8 +148,8 @@ GenericMidiControlProtocol::reload_maps ()
{ {
vector<string *> *midi_maps; vector<string *> *midi_maps;
PathScanner scanner; PathScanner scanner;
SearchPath spath (system_midi_map_search_path()); SearchPath spath (system_midi_map_search_path().to_string());
spath += user_midi_map_directory (); spath += user_midi_map_directory ().to_string();
midi_maps = scanner (spath.to_string(), midi_map_filter, 0, false, true); midi_maps = scanner (spath.to_string(), midi_map_filter, 0, false, true);

View file

@ -445,7 +445,7 @@ static SearchPath
devinfo_search_path () devinfo_search_path ()
{ {
bool devinfo_path_defined = false; bool devinfo_path_defined = false;
sys::path spath_env (Glib::getenv (devinfo_env_variable_name, devinfo_path_defined)); std::string spath_env (Glib::getenv (devinfo_env_variable_name, devinfo_path_defined));
if (devinfo_path_defined) { if (devinfo_path_defined) {
return spath_env; return spath_env;

View file

@ -26,6 +26,7 @@
#include "pbd/error.h" #include "pbd/error.h"
#include "pbd/pathscanner.h" #include "pbd/pathscanner.h"
#include "pbd/replace_all.h" #include "pbd/replace_all.h"
#include "pbd/filesystem.h"
#include "ardour/filesystem_paths.h" #include "ardour/filesystem_paths.h"
@ -59,7 +60,7 @@ static SearchPath
devprofile_search_path () devprofile_search_path ()
{ {
bool devprofile_path_defined = false; bool devprofile_path_defined = false;
sys::path spath_env (Glib::getenv (devprofile_env_variable_name, devprofile_path_defined)); std::string spath_env (Glib::getenv (devprofile_env_variable_name, devprofile_path_defined));
if (devprofile_path_defined) { if (devprofile_path_defined) {
return spath_env; return spath_env;

View file

@ -189,11 +189,11 @@ OSC::start ()
PBD::info << "OSC @ " << get_server_url () << endmsg; PBD::info << "OSC @ " << get_server_url () << endmsg;
PBD::sys::path url_file; std::string url_file;
if (find_file_in_search_path (ardour_config_search_path(), "osc_url", url_file)) { if (find_file_in_search_path (ardour_config_search_path(), "osc_url", url_file)) {
_osc_url_file = url_file.to_string(); _osc_url_file = url_file;
ofstream urlfile; ofstream urlfile;
urlfile.open(_osc_url_file.c_str(), ios::trunc); urlfile.open(_osc_url_file.c_str(), ios::trunc);