File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -477,6 +477,17 @@ STATIC mp_obj_t stream_tell(mp_obj_t self) {
477477}
478478MP_DEFINE_CONST_FUN_OBJ_1 (mp_stream_tell_obj , stream_tell );
479479
480+ STATIC mp_obj_t stream_flush (mp_obj_t self ) {
481+ const mp_stream_p_t * stream_p = mp_get_stream_raise (self , MP_STREAM_OP_IOCTL );
482+ int error ;
483+ mp_uint_t res = stream_p -> ioctl (self , MP_STREAM_FLUSH , 0 , & error );
484+ if (res == MP_STREAM_ERROR ) {
485+ nlr_raise (mp_obj_new_exception_arg1 (& mp_type_OSError , MP_OBJ_NEW_SMALL_INT (error )));
486+ }
487+ return mp_const_none ;
488+ }
489+ MP_DEFINE_CONST_FUN_OBJ_1 (mp_stream_flush_obj , stream_flush );
490+
480491STATIC mp_obj_t stream_ioctl (size_t n_args , const mp_obj_t * args ) {
481492 const mp_stream_p_t * stream_p = mp_get_stream_raise (args [0 ], MP_STREAM_OP_IOCTL );
482493
Original file line number Diff line number Diff line change @@ -58,6 +58,7 @@ MP_DECLARE_CONST_FUN_OBJ(mp_stream_write_obj);
5858MP_DECLARE_CONST_FUN_OBJ (mp_stream_write1_obj );
5959MP_DECLARE_CONST_FUN_OBJ (mp_stream_seek_obj );
6060MP_DECLARE_CONST_FUN_OBJ (mp_stream_tell_obj );
61+ MP_DECLARE_CONST_FUN_OBJ (mp_stream_flush_obj );
6162MP_DECLARE_CONST_FUN_OBJ (mp_stream_ioctl_obj );
6263
6364// these are for mp_get_stream_raise and can be or'd together
You can’t perform that action at this time.
0 commit comments