diff options
| author | Michel Bouwmans <m.bouwmans@ep-games.eu> | 2021-07-13 10:48:09 +0200 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2021-07-23 13:21:42 +1000 |
| commit | 7870ec03701eb0bac44edf8c98e367a669918658 (patch) | |
| tree | e745f030d8804197350307b187f5396b5917e1f0 | |
| parent | 4e39ff221abff9d1d7d7fc654da67a89a7543112 (diff) | |
tools/mpremote: Add seek whence for mounted files.
Fixes issue #7534.
Signed-off-by: Michel Bouwmans <m.bouwmans@ep-games.eu>
| -rw-r--r-- | tools/mpremote/mpremote/pyboardextended.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/tools/mpremote/mpremote/pyboardextended.py b/tools/mpremote/mpremote/pyboardextended.py index e3f259b39..6f439e2dd 100644 --- a/tools/mpremote/mpremote/pyboardextended.py +++ b/tools/mpremote/mpremote/pyboardextended.py @@ -26,6 +26,7 @@ fs_hook_cmds = { fs_hook_code = """\ import uos, uio, ustruct, micropython, usys +SEEK_SET = 0 class RemoteCommand: def __init__(self, use_second_port): @@ -213,11 +214,12 @@ class RemoteFile(uio.IOBase): c.end() return n - def seek(self, n): + def seek(self, n, whence=SEEK_SET): c = self.cmd c.begin(CMD_SEEK) c.wr_s8(self.fd) c.wr_s32(n) + c.wr_s8(whence) n = c.rd_s32() c.end() return n @@ -459,8 +461,9 @@ class PyboardCommand: def do_seek(self): fd = self.rd_s8() n = self.rd_s32() + whence = self.rd_s8() # self.log_cmd(f"seek {fd} {n}") - self.data_files[fd][0].seek(n) + n = self.data_files[fd][0].seek(n, whence) self.wr_s32(n) def do_write(self): |
