From 873a55addf3cda9bce6b2f81c14119120aca1d10 Mon Sep 17 00:00:00 2001 From: Steffen Schuemann Date: Sat, 22 May 2021 07:14:47 +0200 Subject: [PATCH] refs #122, fix for dead symlink iteration error --- README.md | 2 ++ include/ghc/filesystem.hpp | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7d50f40..7977f77 100644 --- a/README.md +++ b/README.md @@ -551,6 +551,8 @@ to the expected behavior. ### v1.5.5 (WIP) +* Fix for [#122](https://github.com/gulrak/filesystem/issues/122), incrementing + the `recursive_directory_iterator` will not try to enter dead symlinks. * Fix for [#119](https://github.com/gulrak/filesystem/issues/119), added missing support for char16_t and char32_t and on C++20 char8_t literals. * Pull request [#118](https://github.com/gulrak/filesystem/pull/118), when diff --git a/include/ghc/filesystem.hpp b/include/ghc/filesystem.hpp index bc55b51..9c06a74 100644 --- a/include/ghc/filesystem.hpp +++ b/include/ghc/filesystem.hpp @@ -5802,8 +5802,11 @@ GHC_INLINE recursive_directory_iterator& recursive_directory_iterator::operator+ GHC_INLINE recursive_directory_iterator& recursive_directory_iterator::increment(std::error_code& ec) noexcept { - bool isDir = (*this)->is_directory(ec); - bool isSymLink = !ec && (*this)->is_symlink(ec); + bool isSymLink = (*this)->is_symlink(ec); + bool isDir = !ec && (*this)->is_directory(ec); + if(isSymLink && detail::is_not_found_error(ec)) { + ec.clear(); + } if(!ec) { if (recursion_pending() && isDir && (!isSymLink || (options() & directory_options::follow_directory_symlink) != directory_options::none)) { _impl->_dir_iter_stack.push(directory_iterator((*this)->path(), _impl->_options, ec));