Attempts to descend into a directory
| 1460 | { |
| 1461 | //! Attempts to descend into a directory |
| 1462 | static push_directory_result push_directory(detail::recur_dir_itr_imp* imp, system::error_code& ec) |
| 1463 | { |
| 1464 | push_directory_result result = directory_not_pushed; |
| 1465 | try |
| 1466 | { |
| 1467 | // Discover if the iterator is for a directory that needs to be recursed into, |
| 1468 | // taking symlinks and options into account. |
| 1469 | |
| 1470 | if ((imp->m_options & directory_options::_detail_no_push) != directory_options::none) |
| 1471 | { |
| 1472 | imp->m_options &= ~directory_options::_detail_no_push; |
| 1473 | return result; |
| 1474 | } |
| 1475 | |
| 1476 | file_type symlink_ft = status_error; |
| 1477 | |
| 1478 | #if defined(BOOST_FILESYSTEM_POSIX_API) && defined(BOOST_FILESYSTEM_HAS_FDOPENDIR_NOFOLLOW) && defined(BOOST_FILESYSTEM_HAS_POSIX_AT_APIS) |
| 1479 | int parentdir_fd = -1; |
| 1480 | path dir_it_filename; |
| 1481 | #elif defined(BOOST_FILESYSTEM_WINDOWS_API) |
| 1482 | unique_handle direntry_handle; |
| 1483 | #endif |
| 1484 | |
| 1485 | // If we are not recursing into symlinks, we are going to have to know if the |
| 1486 | // stack top is a symlink, so get symlink_status and verify no error occurred. |
| 1487 | if ((imp->m_options & directory_options::follow_directory_symlink) == directory_options::none || |
| 1488 | (imp->m_options & directory_options::skip_dangling_symlinks) != directory_options::none) |
| 1489 | { |
| 1490 | directory_iterator const& dir_it = imp->m_stack.back(); |
| 1491 | if (!filesystem::type_present(dir_it->m_symlink_status)) |
| 1492 | { |
| 1493 | #if defined(BOOST_FILESYSTEM_POSIX_API) |
| 1494 | |
| 1495 | #if defined(BOOST_FILESYSTEM_HAS_FDOPENDIR_NOFOLLOW) && defined(BOOST_FILESYSTEM_HAS_POSIX_AT_APIS) |
| 1496 | parentdir_fd = dir_itr_fd(*dir_it.m_imp, ec); |
| 1497 | if (BOOST_UNLIKELY(!!ec)) |
| 1498 | return result; |
| 1499 | |
| 1500 | dir_it_filename = detail::path_algorithms::filename_v4(dir_it->path()); |
| 1501 | |
| 1502 | dir_it->m_symlink_status = detail::symlink_status_impl(dir_it_filename, &ec, parentdir_fd); |
| 1503 | #else // defined(BOOST_FILESYSTEM_HAS_FDOPENDIR_NOFOLLOW) && defined(BOOST_FILESYSTEM_HAS_POSIX_AT_APIS) |
| 1504 | dir_it->m_symlink_status = detail::symlink_status_impl(dir_it->path(), &ec); |
| 1505 | #endif // defined(BOOST_FILESYSTEM_HAS_FDOPENDIR_NOFOLLOW) && defined(BOOST_FILESYSTEM_HAS_POSIX_AT_APIS) |
| 1506 | if (BOOST_UNLIKELY(!!ec)) |
| 1507 | return result; |
| 1508 | |
| 1509 | #else // defined(BOOST_FILESYSTEM_POSIX_API) |
| 1510 | |
| 1511 | boost::winapi::NTSTATUS_ status = nt_create_file_handle_at |
| 1512 | ( |
| 1513 | direntry_handle, |
| 1514 | static_cast< HANDLE >(dir_it.m_imp->handle), |
| 1515 | detail::path_algorithms::filename_v4(dir_it->path()), |
| 1516 | 0u, // FileAttributes |
| 1517 | FILE_LIST_DIRECTORY | FILE_READ_ATTRIBUTES | FILE_READ_EA | SYNCHRONIZE, |
| 1518 | FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, |
| 1519 | FILE_OPEN, |
nothing calls this directly
no test coverage detected