diff options
author | Alex March <alex.march.dev@gmail.com> | 2016-10-18 14:18:15 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2016-10-19 15:57:07 +1100 |
commit | 84679e0c065adb357af39b9efbffcf0f3991eece (patch) | |
tree | 87c776ad53a7f1da4e4fa82c95ddbedeb7b76a6b /extmod/vfs_fat_file.c | |
parent | 17ba6ef5fa7585d3e91dada3044e8e755cf99537 (diff) | |
download | micropython-84679e0c065adb357af39b9efbffcf0f3991eece.tar.gz micropython-84679e0c065adb357af39b9efbffcf0f3991eece.zip |
extmod/vfs_fat_file: Check fatfs f_sync() and f_close() returns for errors.
Diffstat (limited to 'extmod/vfs_fat_file.c')
-rw-r--r-- | extmod/vfs_fat_file.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/extmod/vfs_fat_file.c b/extmod/vfs_fat_file.c index ecc9ed70f9..e269ef593c 100644 --- a/extmod/vfs_fat_file.c +++ b/extmod/vfs_fat_file.c @@ -110,14 +110,20 @@ STATIC mp_uint_t file_obj_write(mp_obj_t self_in, const void *buf, mp_uint_t siz STATIC mp_obj_t file_obj_flush(mp_obj_t self_in) { pyb_file_obj_t *self = MP_OBJ_TO_PTR(self_in); - f_sync(&self->fp); + FRESULT res = f_sync(&self->fp); + if (res != FR_OK) { + mp_raise_OSError(fresult_to_errno_table[res]); + } return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_1(file_obj_flush_obj, file_obj_flush); STATIC mp_obj_t file_obj_close(mp_obj_t self_in) { pyb_file_obj_t *self = MP_OBJ_TO_PTR(self_in); - f_close(&self->fp); + FRESULT res = f_close(&self->fp); + if (res != FR_OK) { + mp_raise_OSError(fresult_to_errno_table[res]); + } return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_1(file_obj_close_obj, file_obj_close); |