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

Function main

example/tut4.cpp:18–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16using namespace boost::filesystem;
17
18int main(int argc, char* argv[])
19{
20 if (argc < 2)
21 {
22 cout << "Usage: tut4 path\n";
23 return 1;
24 }
25
26 path p(argv[1]);
27
28 try
29 {
30 if (exists(p))
31 {
32 if (is_regular_file(p))
33 {
34 cout << p << " size is " << file_size(p) << '\n';
35 }
36 else if (is_directory(p))
37 {
38 cout << p << " is a directory containing:\n";
39
40 std::vector< path > v;
41
42 for (auto&& x : directory_iterator(p))
43 v.push_back(x.path());
44
45 std::sort(v.begin(), v.end());
46
47 for (auto&& x : v)
48 cout << " " << x.filename() << '\n';
49 }
50 else
51 cout << p << " exists, but is not a regular file or directory\n";
52 }
53 else
54 cout << p << " does not exist\n";
55 }
56 catch (filesystem_error& ex)
57 {
58 cout << ex.what() << '\n';
59 }
60
61 return 0;
62}

Callers

nothing calls this directly

Calls 10

directory_iteratorClass · 0.85
pathMethod · 0.80
filenameMethod · 0.80
whatMethod · 0.80
existsFunction · 0.50
is_regular_fileFunction · 0.50
file_sizeFunction · 0.50
is_directoryFunction · 0.50
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected