| 19 | } |
| 20 | |
| 21 | int main(int argc, char* argv[]) |
| 22 | { |
| 23 | if (argc < 2) |
| 24 | { |
| 25 | cout << "Usage: path_info path-element [path-element...]\n" |
| 26 | "Composes a path via operator/= from one or more path-element arguments\n" |
| 27 | "Example: path_info foo/bar baz\n" |
| 28 | #ifdef BOOST_FILESYSTEM_POSIX_API |
| 29 | " would report info about the composed path foo/bar/baz\n"; |
| 30 | #else // BOOST_FILESYSTEM_WINDOWS_API |
| 31 | " would report info about the composed path foo/bar\\baz\n"; |
| 32 | #endif |
| 33 | return 1; |
| 34 | } |
| 35 | |
| 36 | path p; |
| 37 | for (; argc > 1; --argc, ++argv) |
| 38 | p /= argv[1]; // compose path p from the command line arguments |
| 39 | |
| 40 | cout << "\ncomposed path:\n"; |
| 41 | cout << " operator<<()---------: " << p << "\n"; |
| 42 | cout << " make_preferred()-----: " << p.make_preferred() << "\n"; |
| 43 | |
| 44 | cout << "\nelements:\n"; |
| 45 | for (auto element : p) |
| 46 | cout << " " << element << '\n'; |
| 47 | |
| 48 | cout << "\nobservers, native format:" << endl; |
| 49 | #ifdef BOOST_FILESYSTEM_POSIX_API |
| 50 | cout << " native()-------------: " << p.native() << endl; |
| 51 | cout << " c_str()--------------: " << p.c_str() << endl; |
| 52 | #else // BOOST_FILESYSTEM_WINDOWS_API |
| 53 | wcout << L" native()-------------: " << p.native() << endl; |
| 54 | wcout << L" c_str()--------------: " << p.c_str() << endl; |
| 55 | #endif |
| 56 | cout << " string()-------------: " << p.string() << endl; |
| 57 | wcout << L" wstring()------------: " << p.wstring() << endl; |
| 58 | |
| 59 | cout << "\nobservers, generic format:\n"; |
| 60 | cout << " generic_string()-----: " << p.generic_string() << endl; |
| 61 | wcout << L" generic_wstring()----: " << p.generic_wstring() << endl; |
| 62 | |
| 63 | cout << "\ndecomposition:\n"; |
| 64 | cout << " root_name()----------: " << p.root_name() << '\n'; |
| 65 | cout << " root_directory()-----: " << p.root_directory() << '\n'; |
| 66 | cout << " root_path()----------: " << p.root_path() << '\n'; |
| 67 | cout << " relative_path()------: " << p.relative_path() << '\n'; |
| 68 | cout << " parent_path()--------: " << p.parent_path() << '\n'; |
| 69 | cout << " filename()-----------: " << p.filename() << '\n'; |
| 70 | cout << " stem()---------------: " << p.stem() << '\n'; |
| 71 | cout << " extension()----------: " << p.extension() << '\n'; |
| 72 | |
| 73 | cout << "\nquery:\n"; |
| 74 | cout << " empty()--------------: " << say_what(p.empty()) << '\n'; |
| 75 | cout << " is_absolute()--------: " << say_what(p.is_absolute()) << '\n'; |
| 76 | cout << " has_root_name()------: " << say_what(p.has_root_name()) << '\n'; |
| 77 | cout << " has_root_directory()-: " << say_what(p.has_root_directory()) << '\n'; |
| 78 | cout << " has_root_path()------: " << say_what(p.has_root_path()) << '\n'; |
nothing calls this directly
no test coverage detected