28#include <boost/algorithm/string.hpp>
29#include <boost/filesystem/operations.hpp>
30#include <boost/filesystem/path.hpp>
37class directory_iterator;
40class recursive_directory_iterator;
46using boost::filesystem::directory_iterator;
47using boost::filesystem::recursive_directory_iterator;
50inline namespace Kernel {
81 string multiple_path{};
85 if (current_env.
hasKey(path_like_env_variable)) {
86 multiple_path = current_env[path_like_env_variable];
88 log.warn() <<
"Environment variable \"" << path_like_env_variable <<
"\" is not defined !";
93 boost::split(path_elements, multiple_path, boost::is_any_of(
";:"));
96 for (
string path_element : path_elements) {
98 if (boost::filesystem::exists(path_element) && boost::filesystem::is_directory(path_element)) {
101 search_results.insert(search_results.end(), single_path_results.cbegin(), single_path_results.cend());
104 return search_results;
Defines a class to handle the Environment.
provide functions to retrieve resources pointed by environment variables
Python dictionary-like Environment interface.
static bool hasKey(const std::string &)
static Logging getLogger(const std::string &name="")
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
template vector< Path::Item > pathSearch< Path::Item, directory_iterator >(const string &searched_name, Path::Item 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::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< Path::Item > pathSearch< Path::Item, recursive_directory_iterator >(const string &searched_name, Path::Item directory)