| 14 | using namespace boost::filesystem; |
| 15 | |
| 16 | int main(int argc, char* argv[]) |
| 17 | { |
| 18 | if (argc < 2) |
| 19 | { |
| 20 | cout << "Usage: tut3 path\n"; |
| 21 | return 1; |
| 22 | } |
| 23 | |
| 24 | path p(argv[1]); |
| 25 | |
| 26 | try |
| 27 | { |
| 28 | if (exists(p)) |
| 29 | { |
| 30 | if (is_regular_file(p)) |
| 31 | { |
| 32 | cout << p << " size is " << file_size(p) << '\n'; |
| 33 | } |
| 34 | else if (is_directory(p)) |
| 35 | { |
| 36 | cout << p << " is a directory containing:\n"; |
| 37 | |
| 38 | for (directory_entry const& x : directory_iterator(p)) |
| 39 | cout << " " << x.path() << '\n'; |
| 40 | } |
| 41 | else |
| 42 | cout << p << " exists, but is not a regular file or directory\n"; |
| 43 | } |
| 44 | else |
| 45 | cout << p << " does not exist\n"; |
| 46 | } |
| 47 | catch (filesystem_error& ex) |
| 48 | { |
| 49 | cout << ex.what() << '\n'; |
| 50 | } |
| 51 | |
| 52 | return 0; |
| 53 | } |
nothing calls this directly
no test coverage detected