| ... | @@ -1134,7 +1134,8 @@ pub const Dir = struct { | ... | @@ -1134,7 +1134,8 @@ pub const Dir = struct { |
| 1134 | // non-Linux POSIX systems return EPERM when trying to delete a directory, so | 1134 | // non-Linux POSIX systems return EPERM when trying to delete a directory, so |
| 1135 | // we need to handle that case specifically and translate the error | 1135 | // we need to handle that case specifically and translate the error |
| 1136 | .macosx, .ios, .freebsd, .netbsd, .dragonfly => { | 1136 | .macosx, .ios, .freebsd, .netbsd, .dragonfly => { |
| 1137 | const fstat = os.fstatatZ(self.fd, sub_path_c, 0) catch return e; | 1137 | // Don't follow symlinks to match unlinkat (which acts on symlinks rather than follows them) |
| | 1138 | const fstat = os.fstatatZ(self.fd, sub_path_c, os.AT_SYMLINK_NOFOLLOW) catch return e; |
| 1138 | const is_dir = fstat.mode & os.S_IFMT == os.S_IFDIR; | 1139 | const is_dir = fstat.mode & os.S_IFMT == os.S_IFDIR; |
| 1139 | return if (is_dir) error.IsDir else e; | 1140 | return if (is_dir) error.IsDir else e; |
| 1140 | }, | 1141 | }, |