13
0

Add PBD::Searchpath::contains method to check if a Searchpath contains a path

This commit is contained in:
Tim Mayberry 2015-10-19 14:46:50 +10:00 committed by Paul Davis
parent c07ea1bc73
commit 3bd928591b
2 changed files with 15 additions and 0 deletions

View File

@ -134,6 +134,10 @@ public:
*/
LIBPBD_TEMPLATE_MEMBER_API void remove_directories (const std::vector<std::string>& paths);
/**
* @return true if Searchpath already contains path
*/
LIBPBD_TEMPLATE_MEMBER_API bool contains (const std::string& path) const;
};
LIBPBD_API void export_search_path (const std::string& base_dir, const char* varname, const char* dir);

View File

@ -163,6 +163,17 @@ Searchpath::add_subdirectory_to_paths (const string& subdir)
return *this;
}
bool
Searchpath::contains (const string& path) const
{
std::vector<std::string>::const_iterator i = find(begin(), end(), path);
if (i == end()) {
return false;
}
return true;
}
/* This is not part of the Searchpath object, but is closely related to the
* whole idea, and we put it here for convenience.
*/