| 13 | using namespace boost::filesystem; |
| 14 | |
| 15 | int main(int argc, char* argv[]) |
| 16 | { |
| 17 | if (argc < 2) |
| 18 | { |
| 19 | cout << "Usage: tut2 path\n"; |
| 20 | return 1; |
| 21 | } |
| 22 | |
| 23 | path p (argv[1]); // p reads clearer than argv[1] in the following code |
| 24 | |
| 25 | if (exists(p)) // does p actually exist? |
| 26 | { |
| 27 | if (is_regular_file(p)) // is p a regular file? |
| 28 | cout << p << " size is " << file_size(p) << '\n'; |
| 29 | |
| 30 | else if (is_directory(p)) // is p a directory? |
| 31 | cout << p << " is a directory\n"; |
| 32 | |
| 33 | else |
| 34 | cout << p << " exists, but is neither a regular file nor a directory\n"; |
| 35 | } |
| 36 | else |
| 37 | cout << p << " does not exist\n"; |
| 38 | |
| 39 | return 0; |
| 40 | } |
nothing calls this directly
no test coverage detected