28 #include <boost/algorithm/string.hpp>
29 #include <boost/filesystem.hpp>
39 using boost::filesystem::directory_iterator;
40 using boost::filesystem::recursive_directory_iterator;
69 const string& path_like_env_variable,
75 string multiple_path {};
77 log.warn() <<
"Environment variable \"" << path_like_env_variable
78 <<
"\" is not defined !";
83 boost::split(path_elements, multiple_path, boost::is_any_of(
";:"));
86 for (
string path_element : path_elements) {
88 if (boost::filesystem::exists(path_element) && boost::filesystem::is_directory(path_element)) {
90 auto single_path_results =
pathSearch(file_name,
91 path { path_element },
93 search_results.insert(search_results.end(),
94 single_path_results.cbegin(), single_path_results.cend());
97 return search_results;
template vector< path > pathSearch< path, recursive_directory_iterator >(const string &searched_name, path directory)
template vector< path > pathSearch< path, directory_iterator >(const string &searched_name, path directory)
template vector< string > pathSearch< string, directory_iterator >(const string &searched_name, string directory)
template vector< string > pathSearch< string, recursive_directory_iterator >(const string &searched_name, string directory)
ELEMENTS_API std::string getEnv(const std::string &var)
get a particular environment variable
This file is intended to iron out all the differences between systems (currently Linux and MacOSX) ...
boost::filesystem::path path
ELEMENTS_API std::vector< boost::filesystem::path > pathSearchInEnvVariable(const std::string &file_name, const std::string &path_like_env_variable, SearchType search_type=SearchType::Recursive)
Searches for a file or a directory in a path pointed by an environment variable. It can contains coll...
static Logging getLogger(const std::string &name="")
defines the base Elements exception class
std::vector< T > pathSearch(const std::string &searched_name, T directory)