]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // filesystem tut6a.cpp --------------------------------------------------------------// |
2 | ||
3 | // Copyright Beman Dawes 2010 | |
4 | ||
5 | // Distributed under the Boost Software License, Version 1.0. | |
6 | // See http://www.boost.org/LICENSE_1_0.txt | |
7 | ||
8 | // Library home page: http://www.boost.org/libs/filesystem | |
9 | ||
10 | #include <iostream> | |
11 | #include <exception> | |
12 | #include <boost/filesystem.hpp> | |
1e59de90 | 13 | |
7c673cae FG |
14 | using namespace boost::filesystem; |
15 | ||
16 | int main(int argc, char* argv[]) | |
17 | { | |
1e59de90 TL |
18 | if (argc < 2) |
19 | { | |
20 | std::cout << "Usage: tut6a path\n"; | |
21 | return 1; | |
22 | } | |
23 | ||
24 | try | |
7c673cae | 25 | { |
1e59de90 TL |
26 | for (recursive_directory_iterator it(argv[1]); |
27 | it != recursive_directory_iterator(); | |
28 | ++it) | |
29 | { | |
30 | if (it.level() > 1) | |
31 | it.pop(); | |
32 | else | |
33 | { | |
34 | for (int i = 0; i <= it.level(); ++i) | |
35 | std::cout << " "; | |
36 | ||
37 | std::cout << it->path() << '\n'; | |
38 | } | |
39 | } | |
7c673cae | 40 | } |
1e59de90 TL |
41 | catch (std::exception& ex) |
42 | { | |
43 | std::cout << "************* exception *****************\n"; | |
44 | std::cout << ex.what() << '\n'; | |
45 | } | |
46 | ||
47 | return 0; | |
48 | } |