28 #include <boost/algorithm/string.hpp>
29 #include <boost/filesystem/operations.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,
93 search_results.insert(search_results.end(),
94 single_path_results.cbegin(), single_path_results.cend());
97 return search_results;
defines the base Elements exception class
provide functions to retrieve resources pointed by environment variables
This file is intended to iron out all the differences between systems (currently Linux and MacOSX)
static Logging getLogger(const std::string &name="")
ELEMENTS_API auto split(Args &&... args) -> decltype(splitPath(std::forward< Args >(args)...))
alias for the splitPath function
ELEMENTS_API std::vector< T > pathSearch(const std::string &searched_name, T directory, SearchType search_type)
Searches for a file or a directory in a directory. The search can be recursive (SearchType....
boost::filesystem::path Item
ELEMENTS_API std::string getEnv(const std::string &var)
get a particular environment variable
template vector< string > pathSearch< string, directory_iterator >(const string &searched_name, string directory)
ELEMENTS_API std::vector< Path::Item > 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...
template vector< string > pathSearch< string, recursive_directory_iterator >(const string &searched_name, string directory)