@@ -13,7 +13,6 @@ import struct libc.dirent
13
13
import func libc. readdir_r
14
14
import func libc. closedir
15
15
import func libc. opendir
16
- import var libc. DT_DIR
17
16
18
17
19
18
/**
@@ -84,10 +83,10 @@ private class DirectoryContentsGenerator: IteratorProtocol {
84
83
guard readdir_r ( validdir, & entry, & result) == 0 else { continue }
85
84
guard result != nil else { return nil }
86
85
87
- switch ( Int32 ( entry . d_type ) , entry. d_name. 0 , entry. d_name. 1 , entry. d_name. 2 ) {
88
- case ( Int32 ( DT_DIR ) , 46 , 0 , _) : // "."
86
+ switch ( entry. d_name. 0 , entry. d_name. 1 , entry. d_name. 2 ) {
87
+ case ( 46 , 0 , _) : // "."
89
88
continue
90
- case ( Int32 ( DT_DIR ) , 46 , 46 , 0 ) : // ".."
89
+ case ( 46 , 46 , 0 ) : // ".."
91
90
continue
92
91
default :
93
92
return entry
@@ -124,8 +123,9 @@ public class RecursibleDirectoryContentsGenerator: IteratorProtocol, Sequence {
124
123
let name = withUnsafePointer ( & dirName) { ( ptr) -> String in
125
124
return String ( validatingUTF8: UnsafePointer < CChar > ( ptr) ) ?? " "
126
125
}
127
- if Int32 ( entry. d_type) == Int32 ( DT_DIR) {
128
- towalk. append ( Path . join ( current. path, name) )
126
+ let path = Path . join ( current. path, name)
127
+ if path. isDirectory && !path. isSymlink {
128
+ towalk. append ( path)
129
129
}
130
130
return Path . join ( current. path, name)
131
131
}
0 commit comments