From 9599058c35ea9ad7e5e75c867f34300d830c4c34 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 18 May 2018 23:46:10 +0300 Subject: Fix broken dangling symlinks detection by dir_iterator --- libbutl/filesystem.cxx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libbutl/filesystem.cxx b/libbutl/filesystem.cxx index d1b0424..d31ad96 100644 --- a/libbutl/filesystem.cxx +++ b/libbutl/filesystem.cxx @@ -1132,10 +1132,9 @@ namespace butl if (h_ == nullptr) throw_generic_error (errno); - next (); + e_.b_ = d; // Used by next() to detect dangling symlinks. - if (h_ != nullptr) - e_.b_ = d; + next (); h.release (); } @@ -1202,14 +1201,15 @@ namespace butl // If requested, we ignore dangling symlinks, skipping ones with // non-existing or inaccessible targets. // - // Note that ltype () can potentially lstat() and so throw. + // Note that ltype () can potentially lstat() (see d_type() for + // details) and so throw. // if (ignore_dangling_ && e_.ltype () == entry_type::symlink) { struct stat s; - path p (e_.base () / e_.path ()); + path pe (e_.base () / e_.path ()); - if (stat (p.string ().c_str (), &s) != 0) + if (stat (pe.string ().c_str (), &s) != 0) { if (errno == ENOENT || errno == ENOTDIR || errno == EACCES) continue; -- cgit v1.1