MCPcopy Create free account
hub / github.com/boostorg/filesystem / main

Function main

example/path_info.cpp:17–83  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15const char * say_what(bool b) { return b ? "true" : "false"; }
16
17int main(int argc, char* argv[])
18{
19 if (argc < 2)
20 {
21 cout << "Usage: path_info path-portion...\n"
22 "Example: path_info foo/bar baz\n"
23# ifdef BOOST_POSIX_API
24 " would report info about the composed path foo/bar/baz\n";
25# else // BOOST_WINDOWS_API
26 " would report info about the composed path foo/bar\\baz\n";
27# endif
28 return 1;
29 }
30
31 path p; // compose a path from the command line arguments
32
33 for (; argc > 1; --argc, ++argv)
34 p /= argv[1];
35
36 cout << "\ncomposed path:\n";
37 cout << " cout << -------------: " << p << "\n";
38 cout << " make_preferred()----------: " << path(p).make_preferred() << "\n";
39
40 cout << "\nelements:\n";
41
42 for (path::iterator it(p.begin()), it_end(p.end()); it != it_end; ++it)
43 cout << " " << *it << '\n';
44
45 cout << "\nobservers, native format:" << endl;
46# ifdef BOOST_POSIX_API
47 cout << " native()-------------: " << p.native() << endl;
48 cout << " c_str()--------------: " << p.c_str() << endl;
49# else // BOOST_WINDOWS_API
50 wcout << L" native()-------------: " << p.native() << endl;
51 wcout << L" c_str()--------------: " << p.c_str() << endl;
52# endif
53 cout << " string()-------------: " << p.string() << endl;
54 wcout << L" wstring()------------: " << p.wstring() << endl;
55
56 cout << "\nobservers, generic format:\n";
57 cout << " generic_string()-----: " << p.generic_string() << endl;
58 wcout << L" generic_wstring()----: " << p.generic_wstring() << endl;
59
60 cout << "\ndecomposition:\n";
61 cout << " root_name()----------: " << p.root_name() << '\n';
62 cout << " root_directory()-----: " << p.root_directory() << '\n';
63 cout << " root_path()----------: " << p.root_path() << '\n';
64 cout << " relative_path()------: " << p.relative_path() << '\n';
65 cout << " parent_path()--------: " << p.parent_path() << '\n';
66 cout << " filename()-----------: " << p.filename() << '\n';
67 cout << " stem()---------------: " << p.stem() << '\n';
68 cout << " extension()----------: " << p.extension() << '\n';
69
70 cout << "\nquery:\n";
71 cout << " empty()--------------: " << say_what(p.empty()) << '\n';
72 cout << " is_absolute()--------: " << say_what(p.is_absolute()) << '\n';
73 cout << " has_root_name()------: " << say_what(p.has_root_name()) << '\n';
74 cout << " has_root_directory()-: " << say_what(p.has_root_directory()) << '\n';

Callers

nothing calls this directly

Calls 14

say_whatFunction · 0.85
beginMethod · 0.80
endMethod · 0.80
generic_stringMethod · 0.80
generic_wstringMethod · 0.80
root_nameMethod · 0.80
root_directoryMethod · 0.80
root_pathMethod · 0.80
relative_pathMethod · 0.80
parent_pathMethod · 0.80
filenameMethod · 0.80
stemMethod · 0.80

Tested by

no test coverage detected