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

Function directory_iterator_increment

src/directory.cpp:1270–1324  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1268}
1269
1270BOOST_FILESYSTEM_DECL
1271void directory_iterator_increment(directory_iterator& it, system::error_code* ec)
1272{
1273 BOOST_ASSERT_MSG(!it.is_end(), "attempt to increment end iterator");
1274
1275 if (ec)
1276 ec->clear();
1277
1278 try
1279 {
1280 path filename;
1281 file_status file_stat, symlink_file_stat;
1282 system::error_code increment_ec;
1283
1284 while (true)
1285 {
1286 increment_ec = dir_itr_increment(*it.m_imp, filename, file_stat, symlink_file_stat);
1287
1288 if (BOOST_UNLIKELY(!!increment_ec)) // happens if filesystem is corrupt, such as on a damaged optical disc
1289 {
1290 boost::intrusive_ptr< detail::dir_itr_imp > imp;
1291 imp.swap(it.m_imp);
1292 path error_path(imp->dir_entry.path().parent_path()); // fix ticket #5900
1293 if (!ec)
1294 BOOST_FILESYSTEM_THROW(filesystem_error("boost::filesystem::directory_iterator::operator++", error_path, increment_ec));
1295
1296 *ec = increment_ec;
1297 return;
1298 }
1299
1300 if (it.m_imp->handle == nullptr) // eof, make end
1301 {
1302 it.m_imp.reset();
1303 return;
1304 }
1305
1306 const path::string_type::value_type* filename_str = filename.c_str();
1307 if (!(filename_str[0] == path::dot // !(dot or dot-dot)
1308 && (filename_str[1] == static_cast< path::string_type::value_type >('\0') ||
1309 (filename_str[1] == path::dot && filename_str[2] == static_cast< path::string_type::value_type >('\0')))))
1310 {
1311 it.m_imp->dir_entry.replace_filename_with_status(filename, file_stat, symlink_file_stat);
1312 return;
1313 }
1314 }
1315 }
1316 catch (std::bad_alloc&)
1317 {
1318 if (!ec)
1319 throw;
1320
1321 it.m_imp.reset();
1322 *ec = make_error_code(system::errc::not_enough_memory);
1323 }
1324}
1325
1326//--------------------------------------------------------------------------------------//
1327// //

Callers 9

operations.cppFile · 0.85
remove_all_nt6_by_handleFunction · 0.85
remove_all_nt5_implFunction · 0.85
copyFunction · 0.85
directory_iteratorClass · 0.85
incrementMethod · 0.85

Calls 7

dir_itr_incrementFunction · 0.85
clearMethod · 0.80
swapMethod · 0.80
parent_pathMethod · 0.80
pathMethod · 0.80
is_endMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected