extmod/vfs_posix: Use DTTOIF if available to convert type in ilistdir.
This commit is contained in:
parent
3ab2f3fb2b
commit
d974ee1c2f
@ -192,6 +192,9 @@ STATIC mp_obj_t vfs_posix_ilistdir_it_iternext(mp_obj_t self_in) {
|
||||
}
|
||||
|
||||
#ifdef _DIRENT_HAVE_D_TYPE
|
||||
#ifdef DTTOIF
|
||||
t->items[1] = MP_OBJ_NEW_SMALL_INT(DTTOIF(dirent->d_type));
|
||||
#else
|
||||
if (dirent->d_type == DT_DIR) {
|
||||
t->items[1] = MP_OBJ_NEW_SMALL_INT(MP_S_IFDIR);
|
||||
} else if (dirent->d_type == DT_REG) {
|
||||
@ -199,10 +202,12 @@ STATIC mp_obj_t vfs_posix_ilistdir_it_iternext(mp_obj_t self_in) {
|
||||
} else {
|
||||
t->items[1] = MP_OBJ_NEW_SMALL_INT(dirent->d_type);
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
// DT_UNKNOWN should have 0 value on any reasonable system
|
||||
t->items[1] = MP_OBJ_NEW_SMALL_INT(0);
|
||||
#endif
|
||||
|
||||
#ifdef _DIRENT_HAVE_D_INO
|
||||
t->items[2] = MP_OBJ_NEW_SMALL_INT(dirent->d_ino);
|
||||
#else
|
||||
|
Loading…
Reference in New Issue
Block a user