+const std::set<std::string> dump_glob_filenames(const glob_t &globbuf) {
+ std::set<std::string> set;
+
+ for (unsigned i = 0; i < globbuf.gl_pathc; ++i) {
+ std::string filename(globbuf.gl_pathv[i]);
+ set.insert(filename.substr(filename.find_last_of(directorySeparator)+1));
+ }
+
+ return set;
+}
+
+const std::set<std::string> glob_filenames(const std::string &source, const std::string &wildcard) {
+ //for finding files matching pattern in directory
+ glob_t globbuf;
+ std::string pattern = source + wildcard;
+
+ //for freeing allocated memory
+ GlobPtr globbufPtr(&globbuf);
+
+ //actually find files matching pattern in directory - including dotfiles
+ RUNNER_ASSERT_MSG(0 == glob(pattern.c_str(), GLOB_NOSORT | GLOB_PERIOD, NULL, &globbuf),
+ "Failed to search for requested pathnames in " << source << ".");
+
+ return dump_glob_filenames(globbuf);
+}
+
+const std::set<std::string> db_files_pathnames(const std::string &source) {
+ return glob_filenames(source, directoryWildcard);
+}
+
+std::ostream& operator<<(std::ostream& os, const std::set<std::string> &set)
+{
+ os << "{";
+ for (const auto &item : set) {
+ os << " " << item;
+ }
+ os << " }";
+ return os;
+}
+