| 1268 | } |
| 1269 | |
| 1270 | BOOST_FILESYSTEM_DECL |
| 1271 | void 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 | // // |
no test coverage detected