Skip to content

Commit d974ee1

Browse files
committed
extmod/vfs_posix: Use DTTOIF if available to convert type in ilistdir.
1 parent 3ab2f3f commit d974ee1

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

extmod/vfs_posix.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,17 +192,22 @@ STATIC mp_obj_t vfs_posix_ilistdir_it_iternext(mp_obj_t self_in) {
192192
}
193193

194194
#ifdef _DIRENT_HAVE_D_TYPE
195+
#ifdef DTTOIF
196+
t->items[1] = MP_OBJ_NEW_SMALL_INT(DTTOIF(dirent->d_type));
197+
#else
195198
if (dirent->d_type == DT_DIR) {
196199
t->items[1] = MP_OBJ_NEW_SMALL_INT(MP_S_IFDIR);
197200
} else if (dirent->d_type == DT_REG) {
198201
t->items[1] = MP_OBJ_NEW_SMALL_INT(MP_S_IFREG);
199202
} else {
200203
t->items[1] = MP_OBJ_NEW_SMALL_INT(dirent->d_type);
201204
}
205+
#endif
202206
#else
203207
// DT_UNKNOWN should have 0 value on any reasonable system
204208
t->items[1] = MP_OBJ_NEW_SMALL_INT(0);
205209
#endif
210+
206211
#ifdef _DIRENT_HAVE_D_INO
207212
t->items[2] = MP_OBJ_NEW_SMALL_INT(dirent->d_ino);
208213
#else

0 commit comments

Comments
 (0)