X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fpbd%2Fsearch_path.cc;h=3f7be5aa56d7c2d1aa0db51b088724f81675666a;hb=027f0e156a4ed764b4a507b8bf81e0764ec0b6d2;hp=9a10557dabaae7e5bcd8c5a3b93edaf3793c7507;hpb=2c8d0460c2f99c2027d78c090b80d8df95d6f1e6;p=ardour.git diff --git a/libs/pbd/search_path.cc b/libs/pbd/search_path.cc index 9a10557dab..3f7be5aa56 100644 --- a/libs/pbd/search_path.cc +++ b/libs/pbd/search_path.cc @@ -17,9 +17,13 @@ */ -#include -#include -#include +#include + +#include "pbd/tokenizer.h" +#include "pbd/search_path.h" +#include "pbd/error.h" + +using namespace std; namespace { @@ -40,51 +44,41 @@ SearchPath::SearchPath () SearchPath::SearchPath (const string& path) { - vector tmp; - - if(!tokenize ( path, string(path_delimiter), std::back_inserter (tmp))) - { - // log warning(info perhaps?) that the path is empty - warning << "SearchPath contains no tokens" << endmsg; + vector tmp; + if (tokenize (path, string(path_delimiter), std::back_inserter (tmp))) { + add_directories (tmp); } - - add_directories (tmp); } -SearchPath::SearchPath (const vector& paths) +SearchPath::SearchPath (const vector& paths) { add_directories (paths); } -SearchPath::SearchPath (const SearchPath& other) - : m_dirs(other.m_dirs) -{ - -} - void -SearchPath::add_directory (const sys::path& directory_path) +SearchPath::add_directory (const std::string& directory_path) { - // test for existance and warn etc? - m_dirs.push_back(directory_path); + if (!directory_path.empty()) { + push_back(directory_path); + } } void -SearchPath::add_directories (const vector& paths) +SearchPath::add_directories (const vector& paths) { - for(vector::const_iterator i = paths.begin(); i != paths.end(); ++i) { + for(vector::const_iterator i = paths.begin(); i != paths.end(); ++i) { add_directory (*i); } } const string -SearchPath::get_string () const +SearchPath::to_string () const { string path; - for (vector::const_iterator i = m_dirs.begin(); i != m_dirs.end(); ++i) { - path += (*i).to_string(); + for (vector::const_iterator i = begin(); i != end(); ++i) { + path += *i; path += path_delimiter; } @@ -93,29 +87,22 @@ SearchPath::get_string () const return path; } -SearchPath& -SearchPath::operator= (const SearchPath& path) -{ - m_dirs = path.m_dirs; - return *this; -} - SearchPath& SearchPath::operator+= (const SearchPath& spath) { - m_dirs.insert(m_dirs.end(), spath.m_dirs.begin(), spath.m_dirs.end()); + insert(end(), spath.begin(), spath.end()); return *this; } SearchPath& -SearchPath::operator+= (const sys::path& directory_path) +SearchPath::operator+= (const std::string& directory_path) { add_directory (directory_path); return *this; } SearchPath& -SearchPath::operator+ (const sys::path& directory_path) +SearchPath::operator+ (const std::string& directory_path) { add_directory (directory_path); return *this; @@ -125,30 +112,20 @@ SearchPath& SearchPath::operator+ (const SearchPath& spath) { // concatenate paths into new SearchPath - m_dirs.insert(m_dirs.end(), spath.m_dirs.begin(), spath.m_dirs.end()); + insert(end(), spath.begin(), spath.end()); return *this; } SearchPath& SearchPath::add_subdirectory_to_paths (const string& subdir) { - vector tmp; - string directory_path; - - for (vector::iterator i = m_dirs.begin(); i != m_dirs.end(); ++i) - { + for (vector::iterator i = begin(); i != end(); ++i) { // should these new paths just be added to the end of // the search path rather than replace? - *i /= subdir; + *i = Glib::build_filename (*i, subdir); } return *this; } - -SearchPath& -SearchPath::operator/= (const string& subdir) -{ - return add_subdirectory_to_paths (subdir); -} } // namespace PBD