OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
anonymous_namespace{heavyai_glob.cpp} Namespace Reference

Functions

bool has_wildcard (const std::string &name)
 
void glob (const fs::path &base, const fs::path &pattern, std::vector< std::string > &out)
 

Function Documentation

void anonymous_namespace{heavyai_glob.cpp}::glob ( const fs::path &  base,
const fs::path &  pattern,
std::vector< std::string > &  out 
)

Definition at line 40 of file heavyai_glob.cpp.

References heavyai::glob(), and has_wildcard().

40  {
41  if (pattern.empty()) {
42  out.push_back(base.string());
43  return;
44  }
45 
46  auto it = pattern.begin();
47  auto next_part = *(it++);
48  fs::path next_pattern;
49  for (; it != pattern.end(); ++it) {
50  next_pattern /= *it;
51  }
52 
53  if (has_wildcard(next_part.string())) {
54  WIN32_FIND_DATA file_data;
55  auto search = base / next_part;
56 #ifdef _UNICODE
57  auto handle = FindFirstFile(search.wstring().data(), &file_data);
58 #else
59  auto handle = FindFirstFile(search.string().data(), &file_data);
60 #endif
61  if (handle != INVALID_HANDLE_VALUE) {
62  do {
63  fs::path found_part(file_data.cFileName);
64  if (!found_part.filename_is_dot() && !found_part.filename_is_dot_dot()) {
65  glob(base / found_part, next_pattern, out);
66  }
67  } while (FindNextFile(handle, &file_data) != 0);
68  FindClose(handle);
69  }
70  } else {
71  glob(base / next_part, next_pattern, out);
72  }
73 }
bool has_wildcard(const std::string &name)
std::vector< std::string > glob(const std::string &pattern)

+ Here is the call graph for this function:

bool anonymous_namespace{heavyai_glob.cpp}::has_wildcard ( const std::string &  name)

Definition at line 30 of file heavyai_glob.cpp.

Referenced by glob().

30  {
31  if (name.find('*') != std::string::npos) {
32  return true;
33  }
34  if (name.find('?') != std::string::npos) {
35  return true;
36  }
37  return false;
38 }
string name
Definition: setup.in.py:72

+ Here is the caller graph for this function: