py/stream: Add mp_stream_writeall() helper function.

Spools entire output buffer to a blocking stream (chunk by chunk if
needed).
This commit is contained in:
Paul Sokolovsky
2016-03-24 19:09:00 +02:00
parent a5d48b1162
commit d4c8e626f2
2 changed files with 18 additions and 0 deletions

View File

@@ -49,6 +49,9 @@ mp_obj_t mp_stream_unbuffered_iter(mp_obj_t self);
mp_obj_t mp_stream_write(mp_obj_t self_in, const void *buf, size_t len);
// Helper function to write entire buf to *blocking* stream
mp_uint_t mp_stream_writeall(mp_obj_t stream, const byte *buf, mp_uint_t size, int *errcode);
#if MICROPY_STREAMS_NON_BLOCK
// TODO: This is POSIX-specific (but then POSIX is the only real thing,
// and anything else just emulates it, right?)