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

Function main

example/error_demo.cpp:96–200  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

94} // namespace
95
96int main(int argc, char* argv[])
97{
98 if (argc < 2)
99 {
100 cout << "Usage: error_demo path\n";
101 return 1;
102 }
103
104 error_code ec;
105
106 //// construct path - no error_code
107
108 //try { path p1(argv[1]); }
109 //catch (const system_error& ex)
110 //{
111 // cout << "construct path without error_code";
112 // report_system_error(ex);
113 //}
114
115 //// construct path - with error_code
116
117 path p(argv[1]);
118
119 fs::file_status s;
120 bool b(false);
121 fs::directory_iterator di;
122
123 // get status - no error_code
124
125 cout << "\nstatus(\"" << p.string() << "\");\n";
126 threw_exception = false;
127
128 try
129 {
130 s = fs::status(p);
131 }
132 catch (const system_error& ex)
133 {
134 report_filesystem_error(ex);
135 threw_exception = true;
136 }
137 if (!threw_exception)
138 cout << " Did not throw exception\n";
139 report_status(s);
140
141 // get status - with error_code
142
143 cout << "\nstatus(\"" << p.string() << "\", ec);\n";
144 s = fs::status(p, ec);
145 report_status(s);
146 report_error_code(ec);
147
148 // query existence - no error_code
149
150 cout << "\nexists(\"" << p.string() << "\");\n";
151 threw_exception = false;
152
153 try

Callers

nothing calls this directly

Calls 7

report_filesystem_errorFunction · 0.85
report_statusFunction · 0.85
report_error_codeFunction · 0.85
directory_iteratorClass · 0.85
stringMethod · 0.80
statusFunction · 0.50
existsFunction · 0.50

Tested by

no test coverage detected