22 #ifndef ELEMENTSKERNEL_ELEMENTSKERNEL_PATHSEARCH_IMPL_
23 #error "This file should not be included directly! Use ElementsKernel/Path.h instead"
29 #include <boost/filesystem/operations.hpp>
34 inline namespace Kernel {
37 template <
typename T,
typename ITER>
46 if (boost::filesystem::is_directory(l_directory)) {
48 for (ITER dir_iter(l_directory); dir_iter != end_iter; ++dir_iter) {
49 if (dir_iter->path().filename() == searched_name) {
52 T l_result{dir_iter->path().string()};
53 searchResults.emplace_back(l_result);
65 switch (search_type) {
67 searchResults = pathSearch<T, boost::filesystem::directory_iterator>(searched_name, directory);
70 searchResults = pathSearch<T, boost::filesystem::recursive_directory_iterator>(searched_name, directory);
78 return searchOption<T>(searched_name, directory, search_type);
84 #endif // ELEMENTSKERNEL_ELEMENTSKERNEL_PATHSEARCH_IMPL_
boost::filesystem::path Item
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.Recursive) and in that case more than one results can be return.
provide functions to retrieve resources pointed by environment variables