From 1d7f34538d9dd08958671f6606e51a32e237e174 Mon Sep 17 00:00:00 2001 From: kennytm Date: Thu, 2 Jun 2016 00:01:53 +0800 Subject: [PATCH] Restore original meaning of std::fs::read_dir's example changed in #33958. DirEntry.file_type().is_dir() will not follow symlinks, but the original example (fs::metadata(&path).is_dir()) does. Therefore the change in #33958 introduced a subtle difference that now it won't enter linked folders. To preserve the same behavior, we use Path::is_dir() instead, which does follow symlink. --- src/libstd/fs.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index 734f774043d6d..3c742a9ee56e3 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -1341,8 +1341,9 @@ pub fn remove_dir_all>(path: P) -> io::Result<()> { /// if dir.is_dir() { /// for entry in try!(fs::read_dir(dir)) { /// let entry = try!(entry); -/// if try!(entry.file_type()).is_dir() { -/// try!(visit_dirs(&entry.path(), cb)); +/// let path = entry.path(); +/// if path.is_dir() { +/// try!(visit_dirs(&path, cb)); /// } else { /// cb(&entry); /// }