unix/modos: Convert dir-type to stat-type for file type in ilistdir.
Fixes issue #3931.
This commit is contained in:
parent
e2e22e3d7e
commit
3ab2f3fb2b
@ -172,12 +172,24 @@ STATIC mp_obj_t listdir_next(mp_obj_t self_in) {
|
||||
|
||||
mp_obj_tuple_t *t = MP_OBJ_TO_PTR(mp_obj_new_tuple(3, NULL));
|
||||
t->items[0] = mp_obj_new_str(dirent->d_name, strlen(dirent->d_name));
|
||||
|
||||
#ifdef _DIRENT_HAVE_D_TYPE
|
||||
t->items[1] = MP_OBJ_NEW_SMALL_INT(dirent->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) {
|
||||
t->items[1] = MP_OBJ_NEW_SMALL_INT(MP_S_IFREG);
|
||||
} 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