mirror of
https://github.com/micropython/micropython.git
synced 2026-01-07 20:50:14 +01:00
extmod/vfs_fat: Add file size as 4th element of uos.ilistdir tuple.
This commit is contained in:
committed by
Damien George
parent
1345093401
commit
4d3a92c67c
@@ -366,9 +366,7 @@ mp_obj_t mp_vfs_listdir(size_t n_args, const mp_obj_t *args) {
|
||||
mp_obj_t dir_list = mp_obj_new_list(0, NULL);
|
||||
mp_obj_t next;
|
||||
while ((next = mp_iternext(iter)) != MP_OBJ_STOP_ITERATION) {
|
||||
mp_obj_t *items;
|
||||
mp_obj_get_array_fixed_n(next, 3, &items);
|
||||
mp_obj_list_append(dir_list, items[0]);
|
||||
mp_obj_list_append(dir_list, mp_obj_subscr(next, MP_OBJ_NEW_SMALL_INT(0), MP_OBJ_SENTINEL));
|
||||
}
|
||||
return dir_list;
|
||||
}
|
||||
|
||||
@@ -142,8 +142,8 @@ STATIC mp_obj_t mp_vfs_fat_ilistdir_it_iternext(mp_obj_t self_in) {
|
||||
|
||||
// Note that FatFS already filters . and .., so we don't need to
|
||||
|
||||
// make 3-tuple with info about this entry
|
||||
mp_obj_tuple_t *t = MP_OBJ_TO_PTR(mp_obj_new_tuple(3, NULL));
|
||||
// make 4-tuple with info about this entry
|
||||
mp_obj_tuple_t *t = MP_OBJ_TO_PTR(mp_obj_new_tuple(4, NULL));
|
||||
if (self->is_str) {
|
||||
t->items[0] = mp_obj_new_str(fn, strlen(fn));
|
||||
} else {
|
||||
@@ -157,6 +157,7 @@ STATIC mp_obj_t mp_vfs_fat_ilistdir_it_iternext(mp_obj_t self_in) {
|
||||
t->items[1] = MP_OBJ_NEW_SMALL_INT(MP_S_IFREG);
|
||||
}
|
||||
t->items[2] = MP_OBJ_NEW_SMALL_INT(0); // no inode number
|
||||
t->items[3] = mp_obj_new_int_from_uint(fno.fsize);
|
||||
|
||||
return MP_OBJ_FROM_PTR(t);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user