OmniSciDB  471d68cefb
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
shared::anonymous_namespace{file_path_util.cpp} Namespace Reference

Functions

std::vector< std::string > glob_local_recursive_files (const std::string &file_path)
 
std::vector< std::string > regex_file_filter (const std::string &pattern, const std::vector< std::string > &file_paths)
 

Function Documentation

std::vector<std::string> shared::anonymous_namespace{file_path_util.cpp}::glob_local_recursive_files ( const std::string &  file_path)

Definition at line 58 of file file_path_util.cpp.

References omnisci::glob(), and shared::throw_file_not_found().

Referenced by shared::local_glob_filter_sort_files().

58  {
59  std::vector<std::string> file_paths;
60 
61  if (boost::filesystem::is_regular_file(file_path)) {
62  file_paths.emplace_back(file_path);
63  } else if (boost::filesystem::is_directory(file_path)) {
64  for (boost::filesystem::recursive_directory_iterator
65  it(file_path, boost::filesystem::symlink_option::recurse),
66  eit;
67  it != eit;
68  ++it) {
69  if (!boost::filesystem::is_directory(it->path())) {
70  file_paths.emplace_back(it->path().string());
71  }
72  }
73  // empty directories will not throw an error
74  } else {
75  auto glob_results = omnisci::glob(file_path);
76  for (const auto& path : glob_results) {
77  if (boost::filesystem::is_directory(path)) {
78  auto expanded_paths = glob_local_recursive_files(path);
79  file_paths.insert(file_paths.end(), expanded_paths.begin(), expanded_paths.end());
80  } else {
81  file_paths.emplace_back(path);
82  }
83  }
84  if (file_paths.empty()) {
85  throw_file_not_found(file_path);
86  }
87  }
88  return file_paths;
89 }
void throw_file_not_found(const std::string &file_path)
std::vector< std::string > glob(const std::string &pattern)
std::vector< std::string > glob_local_recursive_files(const std::string &file_path)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::vector<std::string> shared::anonymous_namespace{file_path_util.cpp}::regex_file_filter ( const std::string &  pattern,
const std::vector< std::string > &  file_paths 
)

Definition at line 91 of file file_path_util.cpp.

References shared::throw_no_filter_match().

Referenced by shared::local_glob_filter_sort_files().

92  {
93  boost::regex regex_pattern(pattern);
94  std::vector<std::string> matched_file_paths;
95  for (const auto& path : file_paths) {
96  if (boost::regex_match(path, regex_pattern)) {
97  matched_file_paths.emplace_back(path);
98  }
99  }
100  if (matched_file_paths.empty()) {
101  throw_no_filter_match(pattern);
102  }
103  return matched_file_paths;
104 }
void throw_no_filter_match(const std::string &pattern)

+ Here is the call graph for this function:

+ Here is the caller graph for this function: