diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2014-07-08 00:50:09 -0400 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2014-07-08 00:53:13 -0400 |
commit | d3e3f5f0058f45825b46abf731ece39fc416efa0 (patch) | |
tree | 3a760c2cb66941acf219aadd6a47b421615d31a2 /libs/pbd/search_path.cc | |
parent | f4a84a0272c5f5460ccc2e49162a3efb4c92480c (diff) |
add operator-= variants for PBD::Searchpath
Diffstat (limited to 'libs/pbd/search_path.cc')
-rw-r--r-- | libs/pbd/search_path.cc | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/libs/pbd/search_path.cc b/libs/pbd/search_path.cc index 895bc59909..44438cc85c 100644 --- a/libs/pbd/search_path.cc +++ b/libs/pbd/search_path.cc @@ -50,6 +50,30 @@ Searchpath::Searchpath (const vector<std::string>& paths) } void +Searchpath::remove_directory (const std::string& directory_path) +{ + if (directory_path.empty()) { + return; + } + + for (vector<std::string>::iterator i = begin(); i != end();) { + if (*i == directory_path) { + i = erase (i); + } else { + ++i; + } + } +} + +void +Searchpath::remove_directories (const vector<std::string>& paths) +{ + for(vector<std::string>::const_iterator i = paths.begin(); i != paths.end(); ++i) { + remove_directory (*i); + } +} + +void Searchpath::add_directory (const std::string& directory_path) { if (directory_path.empty()) { @@ -116,6 +140,21 @@ Searchpath::operator+ (const Searchpath& spath) } Searchpath& +Searchpath::operator-= (const Searchpath& spath) +{ + remove_directories (spath); + return *this; +} + +Searchpath& +Searchpath::operator-= (const std::string& directory_path) +{ + remove_directory (directory_path); + return *this; +} + + +Searchpath& Searchpath::add_subdirectory_to_paths (const string& subdir) { for (vector<std::string>::iterator i = begin(); i != end(); ++i) { |