1
Fork 0

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:
kennytm 2016-06-02 00:01:53 +08:00
parent 806a5535da
commit 1d7f34538d
No known key found for this signature in database
GPG key ID: FEF6C8051D0E013C

View file

@ -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);
/// }