py: Add stream_tell method, and use for unix and stmhal file tell.
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "py/nlr.h"
|
||||
#include "py/objstr.h"
|
||||
@@ -400,6 +401,14 @@ STATIC mp_obj_t stream_seek(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_stream_seek_obj, 2, 3, stream_seek);
|
||||
|
||||
STATIC mp_obj_t stream_tell(mp_obj_t self) {
|
||||
mp_obj_t offset = MP_OBJ_NEW_SMALL_INT(0);
|
||||
mp_obj_t whence = MP_OBJ_NEW_SMALL_INT(SEEK_CUR);
|
||||
const mp_obj_t args[3] = {self, offset, whence};
|
||||
return stream_seek(3, args);
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(mp_stream_tell_obj, stream_tell);
|
||||
|
||||
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_stream_read_obj, 1, 2, stream_read);
|
||||
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_stream_readinto_obj, 2, 3, stream_readinto);
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(mp_stream_readall_obj, stream_readall);
|
||||
|
||||
Reference in New Issue
Block a user