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.
This commit is contained in:
parent
806a5535da
commit
1d7f34538d
1 changed files with 3 additions and 2 deletions
|
@ -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);
|
||||
/// }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue