extmod/vfs_posix: Use DTTOIF if available to convert type in ilistdir.

This commit is contained in:
Damien George 2018-07-11 16:07:44 +10:00
parent 3ab2f3fb2b
commit d974ee1c2f

View File

@ -192,6 +192,9 @@ STATIC mp_obj_t vfs_posix_ilistdir_it_iternext(mp_obj_t self_in) {
} }
#ifdef _DIRENT_HAVE_D_TYPE #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) { if (dirent->d_type == DT_DIR) {
t->items[1] = MP_OBJ_NEW_SMALL_INT(MP_S_IFDIR); t->items[1] = MP_OBJ_NEW_SMALL_INT(MP_S_IFDIR);
} else if (dirent->d_type == DT_REG) { } 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 { } else {
t->items[1] = MP_OBJ_NEW_SMALL_INT(dirent->d_type); t->items[1] = MP_OBJ_NEW_SMALL_INT(dirent->d_type);
} }
#endif
#else #else
// DT_UNKNOWN should have 0 value on any reasonable system // DT_UNKNOWN should have 0 value on any reasonable system
t->items[1] = MP_OBJ_NEW_SMALL_INT(0); t->items[1] = MP_OBJ_NEW_SMALL_INT(0);
#endif #endif
#ifdef _DIRENT_HAVE_D_INO #ifdef _DIRENT_HAVE_D_INO
t->items[2] = MP_OBJ_NEW_SMALL_INT(dirent->d_ino); t->items[2] = MP_OBJ_NEW_SMALL_INT(dirent->d_ino);
#else #else