22 #ifdef ELEMENTSKERNEL_ELEMENTSKERNEL_PATHSEARCH_IMPL_
27 #include <boost/filesystem/operations.hpp>
35 template<
typename T,
typename ITER>
44 if (boost::filesystem::is_directory(l_directory)) {
46 for (ITER dir_iter(l_directory); dir_iter != end_iter; ++dir_iter) {
47 if (dir_iter->path().filename() == searched_name) {
50 T l_result { dir_iter->path().string() };
51 searchResults.push_back(l_result);
64 switch (search_type) {
66 searchResults = pathSearch<T, boost::filesystem::directory_iterator>(searched_name,
70 searchResults = pathSearch<T, boost::filesystem::recursive_directory_iterator>(
71 searched_name, directory);
82 return searchOption<T>(searched_name, directory, search_type);
88 #endif // ELEMENTSKERNEL_ELEMENTSKERNEL_PATHSEARCH_IMPL_
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.
boost::filesystem::path Item
provide functions to retrieve resources pointed by environment variables