summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2018-07-11 16:07:44 +1000
committerDamien George <damien.p.george@gmail.com>2018-07-11 16:07:44 +1000
commitd974ee1c2fc3256ab367eeeb020921f8a5b0dd61 (patch)
treed8caa9816c0b78974060726f917b8a7d911edcaa
parent3ab2f3fb2b807a49cf4835cfff7b5e5139a1da76 (diff)
extmod/vfs_posix: Use DTTOIF if available to convert type in ilistdir.
-rw-r--r--extmod/vfs_posix.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/extmod/vfs_posix.c b/extmod/vfs_posix.c
index 2810bdd14..4ca7f9b90 100644
--- a/extmod/vfs_posix.c
+++ b/extmod/vfs_posix.c
@@ -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