tut6c.cpp 866 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // filesystem tut6c.cpp --------------------------------------------------------------//
  2. // Copyright Beman Dawes 2010
  3. // Distributed under the Boost Software License, Version 1.0.
  4. // See http://www.boost.org/LICENSE_1_0.txt
  5. // Library home page: http://www.boost.org/libs/filesystem
  6. #include <iostream>
  7. #include <exception>
  8. #include <boost/filesystem.hpp>
  9. #include <boost/system/error_code.hpp>
  10. using namespace boost::filesystem;
  11. using namespace boost::system;
  12. int main(int argc, char* argv[])
  13. {
  14. if (argc < 2)
  15. {
  16. std::cout << "Usage: tut6c path\n";
  17. return 1;
  18. }
  19. error_code ec;
  20. for (recursive_directory_iterator it (argv[1], ec);
  21. it != recursive_directory_iterator();
  22. )
  23. {
  24. for (int i = 0; i <= it.level(); ++i)
  25. std::cout << " ";
  26. std::cout << it->path() << '\n';
  27. it.increment(ec);
  28. }
  29. return 0;
  30. }