tools/mpremote: Add seek whence for mounted files.
Fixes issue #7534. Signed-off-by: Michel Bouwmans <m.bouwmans@ep-games.eu>
This commit is contained in:
parent
4e39ff221a
commit
7870ec0370
|
@ -26,6 +26,7 @@ fs_hook_cmds = {
|
||||||
fs_hook_code = """\
|
fs_hook_code = """\
|
||||||
import uos, uio, ustruct, micropython, usys
|
import uos, uio, ustruct, micropython, usys
|
||||||
|
|
||||||
|
SEEK_SET = 0
|
||||||
|
|
||||||
class RemoteCommand:
|
class RemoteCommand:
|
||||||
def __init__(self, use_second_port):
|
def __init__(self, use_second_port):
|
||||||
|
@ -213,11 +214,12 @@ class RemoteFile(uio.IOBase):
|
||||||
c.end()
|
c.end()
|
||||||
return n
|
return n
|
||||||
|
|
||||||
def seek(self, n):
|
def seek(self, n, whence=SEEK_SET):
|
||||||
c = self.cmd
|
c = self.cmd
|
||||||
c.begin(CMD_SEEK)
|
c.begin(CMD_SEEK)
|
||||||
c.wr_s8(self.fd)
|
c.wr_s8(self.fd)
|
||||||
c.wr_s32(n)
|
c.wr_s32(n)
|
||||||
|
c.wr_s8(whence)
|
||||||
n = c.rd_s32()
|
n = c.rd_s32()
|
||||||
c.end()
|
c.end()
|
||||||
return n
|
return n
|
||||||
|
@ -459,8 +461,9 @@ class PyboardCommand:
|
||||||
def do_seek(self):
|
def do_seek(self):
|
||||||
fd = self.rd_s8()
|
fd = self.rd_s8()
|
||||||
n = self.rd_s32()
|
n = self.rd_s32()
|
||||||
|
whence = self.rd_s8()
|
||||||
# self.log_cmd(f"seek {fd} {n}")
|
# 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)
|
self.wr_s32(n)
|
||||||
|
|
||||||
def do_write(self):
|
def do_write(self):
|
||||||
|
|
Loading…
Reference in New Issue