File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ struct dirent
10
10
{
11
11
long d_ino ;
12
12
unsigned short d_reclen ;
13
+ unsigned char d_type ;
13
14
unsigned short d_namlen ;
14
15
char d_name [MAX_PATH ];
15
16
};
@@ -20,4 +21,14 @@ DIR *opendir(const char *);
20
21
struct dirent * readdir (DIR * );
21
22
int closedir (DIR * );
22
23
24
+ /* File types for 'd_type'. */
25
+ #define DT_UNKNOWN 0
26
+ #define DT_FIFO 1
27
+ #define DT_CHR 2
28
+ #define DT_DIR 4
29
+ #define DT_BLK 6
30
+ #define DT_REG 8
31
+ #define DT_LNK 10
32
+ #define DT_SOCK 12
33
+ #define DT_WHT 14
23
34
#endif
Original file line number Diff line number Diff line change @@ -69,6 +69,7 @@ opendir(const char *dirname)
69
69
d -> handle = INVALID_HANDLE_VALUE ;
70
70
d -> ret .d_ino = 0 ; /* no inodes on win32 */
71
71
d -> ret .d_reclen = 0 ; /* not used on win32 */
72
+ d -> ret .d_type = DT_UNKNOWN ;
72
73
73
74
return d ;
74
75
}
@@ -105,6 +106,15 @@ readdir(DIR *d)
105
106
}
106
107
strcpy (d -> ret .d_name , fd .cFileName ); /* Both strings are MAX_PATH long */
107
108
d -> ret .d_namlen = strlen (d -> ret .d_name );
109
+ /* The only identified types are: directory, regular file or symbolic link */
110
+ if ((fd .dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) != 0 )
111
+ d -> ret .d_type = DT_DIR ;
112
+ /* For reparse points dwReserved0 field will contain the ReparseTag */
113
+ else if ((fd .dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT ) != 0 &&
114
+ (fd .dwReserved0 == IO_REPARSE_TAG_MOUNT_POINT ))
115
+ d -> ret .d_type = DT_LNK ;
116
+ else
117
+ d -> ret .d_type = DT_REG ;
108
118
109
119
return & d -> ret ;
110
120
}
You can’t perform that action at this time.
0 commit comments