Skip to content

Commit d113990

Browse files
committed
Auto merge of #25632 - alexcrichton:dt-dir, r=brson
This "fast path" in `DirEntry::file_type` on Unix wasn't turning out to be so much of a fast path as the `DT_DIR` case wasn't handled, so directories fell back to using `lstat` instead. This commit adds the missing case to return quickly if a path is a directory and `DirEntry::file_type` is used.
2 parents 4c2ebc3 + e7aad28 commit d113990

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/rt/rust_builtin.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,15 @@ rust_list_dir_val(struct dirent* entry_ptr) {
5959

6060
int
6161
rust_dir_get_mode(struct dirent* entry_ptr) {
62-
#if defined(_DIRENT_HAVE_D_TYPE)
62+
#if defined(_DIRENT_HAVE_D_TYPE) || defined(__APPLE__)
6363
switch (entry_ptr->d_type) {
6464
case DT_BLK: return S_IFBLK;
6565
case DT_CHR: return S_IFCHR;
6666
case DT_FIFO: return S_IFIFO;
6767
case DT_LNK: return S_IFLNK;
6868
case DT_REG: return S_IFREG;
6969
case DT_SOCK: return S_IFSOCK;
70+
case DT_DIR: return S_IFDIR;
7071
}
7172
#endif
7273
return -1;

0 commit comments

Comments
 (0)