FileSystem.Unix: Directory.Delete: remove per item syscall. (#59520)
authorTom Deseyn <tom.deseyn@gmail.com>
Tue, 23 Nov 2021 14:51:37 +0000 (15:51 +0100)
committerGitHub <noreply@github.com>
Tue, 23 Nov 2021 14:51:37 +0000 (15:51 +0100)
commita0fdc256404ee92455297ebcfe598f64ac1b7526
tree6dc89b5572630d6244314e1c01c69b2a02712cbb
parent56b5df416f2f41aa5631d41c4a9e4eb9a37e406b
FileSystem.Unix: Directory.Delete: remove per item syscall. (#59520)

* FileSystem.Unix: Directory.Delete: remove per item syscall.

By recursing using FileSystemEnumerable we know the file type and
can omit the stat calls made by DirectoryInfo.Exists.

For the top level path, we can omit the call also and handle
non-directories when rmdir errno is ENOTDIR.

For the recursive case we can avoid recursion when the top level path rmdir
succeeds immediately.

FileSystemEntry is updated so IsSymbolicLink remembers the file is symbolic link
and does not make a syscall for it.
src/libraries/System.IO.FileSystem/tests/Directory/Delete.cs
src/libraries/System.Private.CoreLib/src/System/IO/FileSystem.Unix.cs