shuzhou-s
7/21/2017 - 8:39 AM

List all content in a directory using boost

List all content in a directory using boost

#include <boost/filesystem.hpp>

namespace fs = boost::filesystem;

void list_of_all_content(string dirname){
  fs::path p(dirname);

  if (fs::exists(p) && fs::is_directory(p)) {
    for (fs::directory_entry& x : fs::directory_iterator(p))
      cout << x.path() << endl;
  }
}