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

Function main

example/tut3.cpp:16–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14using namespace boost::filesystem;
15
16int 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}

Callers

nothing calls this directly

Calls 7

directory_iteratorClass · 0.85
pathMethod · 0.80
whatMethod · 0.80
existsFunction · 0.50
is_regular_fileFunction · 0.50
file_sizeFunction · 0.50
is_directoryFunction · 0.50

Tested by

no test coverage detected