File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -477,6 +477,17 @@ STATIC mp_obj_t stream_tell(mp_obj_t self) {
477
477
}
478
478
MP_DEFINE_CONST_FUN_OBJ_1 (mp_stream_tell_obj , stream_tell );
479
479
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
+
480
491
STATIC mp_obj_t stream_ioctl (size_t n_args , const mp_obj_t * args ) {
481
492
const mp_stream_p_t * stream_p = mp_get_stream_raise (args [0 ], MP_STREAM_OP_IOCTL );
482
493
Original file line number Diff line number Diff line change @@ -58,6 +58,7 @@ MP_DECLARE_CONST_FUN_OBJ(mp_stream_write_obj);
58
58
MP_DECLARE_CONST_FUN_OBJ (mp_stream_write1_obj );
59
59
MP_DECLARE_CONST_FUN_OBJ (mp_stream_seek_obj );
60
60
MP_DECLARE_CONST_FUN_OBJ (mp_stream_tell_obj );
61
+ MP_DECLARE_CONST_FUN_OBJ (mp_stream_flush_obj );
61
62
MP_DECLARE_CONST_FUN_OBJ (mp_stream_ioctl_obj );
62
63
63
64
// 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