Skip to content

Commit

Permalink
change order of read_directory() parameters so overloads work properly
Browse files Browse the repository at this point in the history
  • Loading branch information
jordan-evens committed Apr 22, 2024
1 parent 93452f5 commit 82da63b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
9 changes: 5 additions & 4 deletions tbd/src/cpp/Util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ int sxprintf(char* buffer, size_t N, const char* format, ...)
}
namespace tbd::util
{
void read_directory(const string& name, vector<string>* v, const string& match, const bool for_files)
void read_directory(const bool for_files, const string& name, vector<string>* v, const string& match)
{
string full_match = ".*/" + match;
logging::verbose(("Matching '" + full_match + "'").c_str());
Expand All @@ -80,17 +80,18 @@ void read_directory(const string& name, vector<string>* v, const string& match,
#else
v->push_back(entry.path());
#endif
logging::extensive("Found regex match for '%s': %s", match.c_str(), entry.path().string().c_str());
}
}
}
}
void read_directory(const string& name, vector<string>* v, const string& match)
{
read_directory(name, v, match, true);
read_directory(true, name, v, match);
}
void read_directory(const string& name, vector<string>* v, bool for_files)
void read_directory(bool for_files, const string& name, vector<string>* v)
{
read_directory(name, v, "*", for_files);
read_directory(for_files, name, v, "*");
}
void read_directory(const string& name, vector<string>* v)
{
Expand Down
14 changes: 8 additions & 6 deletions tbd/src/cpp/Util.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,15 +219,15 @@ std::basic_istream<Elem, Traits>& getline(
[[nodiscard]] bool directory_exists(const char* dir) noexcept;
/**
* \brief Get a list of items in the given directory matching the given regex
* \param for_files Match files and not directories
* \param name Directory to search
* \param v vector to put found paths into
* \param match regular expression to match in names
* \param for_files Match files and not directories
*/
void read_directory(const string& name,
void read_directory(const bool for_files,
const string& name,
vector<string>* v,
const string& match,
const bool for_files);
const string& match);
/**
* \brief Get a list of files in the given directory matching the given regex
* \param name Directory to search for files
Expand All @@ -239,11 +239,13 @@ void read_directory(const string& name,
const string& match);
/**
* \brief Get a list of items in the given directory matching the given regex
* \param for_files Match files and not directories
* \param name Directory to search
* \param v vector to put found paths into
* \param for_files Match files and not directories
*/
void read_directory(const string& name, vector<string>* v, bool for_files);
void read_directory(const bool for_files,
const string& name,
vector<string>* v);
/**
* \brief Get a list of files in the given directory
* \param name Directory to search for files
Expand Down

0 comments on commit 82da63b

Please sign in to comment.