diff options
| author | kennytm <kennytm@gmail.com> | 2016-06-02 00:01:53 +0800 |
|---|---|---|
| committer | kennytm <kennytm@gmail.com> | 2016-06-02 00:01:53 +0800 |
| commit | 1d7f34538d9dd08958671f6606e51a32e237e174 (patch) | |
| tree | 6c9faf9d77ac255f2e4f678cba727b3eae7546c6 /src | |
| parent | 806a5535dac1afe79176ea7053661953c89eaa5e (diff) | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/libstd/fs.rs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index 734f774043d..3c742a9ee56 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -1341,8 +1341,9 @@ pub fn remove_dir_all<P: AsRef<Path>>(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); /// } |
