diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2018-05-18 23:46:10 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2018-05-18 23:46:10 +0300 |
commit | 9599058c35ea9ad7e5e75c867f34300d830c4c34 (patch) | |
tree | 71ec28b3196beced40ef5e2a0e059790f3bee21e | |
parent | 7129383fde53ab1d74b43f31ed67d50674839f08 (diff) |
Fix broken dangling symlinks detection by dir_iterator
-rw-r--r-- | libbutl/filesystem.cxx | 12 |
1 files 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; |