Skip to content

Commit

Permalink
MINIFICPP-915 - add util to list all of a directory without callback
Browse files Browse the repository at this point in the history
Signed-off-by: Arpad Boda <aboda@apache.org>

This closes #640
  • Loading branch information
dtrodrigues authored and arpadboda committed Sep 4, 2019
1 parent fe480b3 commit a5a260b
Showing 1 changed file with 15 additions and 0 deletions.
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

0 comments on commit a5a260b

Please sign in to comment.