diff options
author | Damien George <damien.p.george@gmail.com> | 2014-07-27 22:38:58 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-07-27 22:38:58 +0100 |
commit | adf0f2ae1a3debf8465ece7e065ddba2d4032e8c (patch) | |
tree | 090c7544536b130b47e30f8834d7450272dfb54a /stmhal/file.c | |
parent | 05c255f039b5c0fbdcb0754748fd5d36135acfd9 (diff) |
py: Change stream protocol API: fns return uint; is_text for text.
Diffstat (limited to 'stmhal/file.c')
-rw-r--r-- | stmhal/file.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/stmhal/file.c b/stmhal/file.c index c1a292490..db6d08e5e 100644 --- a/stmhal/file.c +++ b/stmhal/file.c @@ -73,24 +73,24 @@ void file_obj_print(void (*print)(void *env, const char *fmt, ...), void *env, m print(env, "<io.%s %p>", mp_obj_get_type_str(self_in), self_in); } -STATIC mp_int_t file_obj_read(mp_obj_t self_in, void *buf, mp_uint_t size, int *errcode) { +STATIC mp_uint_t file_obj_read(mp_obj_t self_in, void *buf, mp_uint_t size, int *errcode) { pyb_file_obj_t *self = self_in; UINT sz_out; FRESULT res = f_read(&self->fp, buf, size, &sz_out); if (res != FR_OK) { *errcode = fresult_to_errno_table[res]; - return -1; + return MP_STREAM_ERROR; } return sz_out; } -STATIC mp_int_t file_obj_write(mp_obj_t self_in, const void *buf, mp_uint_t size, int *errcode) { +STATIC mp_uint_t file_obj_write(mp_obj_t self_in, const void *buf, mp_uint_t size, int *errcode) { pyb_file_obj_t *self = self_in; UINT sz_out; FRESULT res = f_write(&self->fp, buf, size, &sz_out); if (res != FR_OK) { *errcode = fresult_to_errno_table[res]; - return -1; + return MP_STREAM_ERROR; } return sz_out; } @@ -240,7 +240,6 @@ STATIC MP_DEFINE_CONST_DICT(rawfile_locals_dict, rawfile_locals_dict_table); STATIC const mp_stream_p_t fileio_stream_p = { .read = file_obj_read, .write = file_obj_write, - .is_bytes = true, }; const mp_obj_type_t mp_type_fileio = { @@ -258,6 +257,7 @@ const mp_obj_type_t mp_type_fileio = { STATIC const mp_stream_p_t textio_stream_p = { .read = file_obj_read, .write = file_obj_write, + .is_text = true, }; const mp_obj_type_t mp_type_textio = { |