Skip to content

Instantly share code, notes, and snippets.

@moriyoshi
Created March 10, 2011 09:11
Show Gist options
  • Save moriyoshi/863800 to your computer and use it in GitHub Desktop.
Save moriyoshi/863800 to your computer and use it in GitHub Desktop.
Recursively traverse directories.
#include <boost/filesystem/convenience.hpp>
#include <boost/foreach.hpp>
#include <boost/range.hpp>
#include <iostream>
int main(int, char**)
{
namespace bf = boost::filesystem;
BOOST_FOREACH(bf::path path,
boost::make_iterator_range(
bf::recursive_directory_iterator(bf::path("/home")),
bf::recursive_directory_iterator())) {
std::cout << path.string() << std::endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment