Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MINIFICPP-915 - add util to list all of a directory without callback #640

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 15 additions & 0 deletions libminifi/include/utils/file/FileUtils.h
Expand Up @@ -19,6 +19,7 @@

#include <sstream>
#include <fstream>
#include <vector>
#ifdef BOOST_VERSION
#include <boost/filesystem.hpp>
#else
Expand Down Expand Up @@ -402,6 +403,20 @@ class FileUtils {
#endif
}

static std::vector<std::pair<std::string, std::string>> list_dir_all(const std::string& dir, const std::shared_ptr<logging::Logger> &logger,
bool recursive = true) {

std::vector<std::pair<std::string, std::string>> fileList;
auto lambda = [&fileList] (const std::string &path, const std::string &filename) {
fileList.push_back(make_pair(path, filename));
return true;
};

list_dir(dir, lambda, logger, recursive);

return fileList;
}

/*
* Provides a platform-independent function to list a directory
* Callback is called for every file found: first argument is the path of the directory, second is the filename
Expand Down