summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Shawcroft <scott@tannewt.org>2018-03-23 14:48:41 -0700
committerGitHub <noreply@github.com>2018-03-23 14:48:41 -0700
commitfa884466793738338edb7389dc6b21f160bba37b (patch)
tree0afcddb2a8e10914bc1ba20e9acd4275d6897157
parent8d376a3efb9229c56d4d90c57368d98f4957bf0b (diff)
parentfa55b15ac6a15be0c11123753760324547518a18 (diff)
Merge pull request #697 from jepler/issue501
extmod/vfs_fat_file: Implement SEEK_CUR for non-zero offset.
-rw-r--r--extmod/vfs_fat_file.c6
-rw-r--r--tests/extmod/vfs_fat_fileio1.py6
-rw-r--r--tests/extmod/vfs_fat_fileio1.py.exp2
3 files changed, 4 insertions, 10 deletions
diff --git a/extmod/vfs_fat_file.c b/extmod/vfs_fat_file.c
index f580184a7..be9c8c792 100644
--- a/extmod/vfs_fat_file.c
+++ b/extmod/vfs_fat_file.c
@@ -125,11 +125,7 @@ STATIC mp_uint_t file_obj_ioctl(mp_obj_t o_in, mp_uint_t request, uintptr_t arg,
break;
case 1: // SEEK_CUR
- if (s->offset != 0) {
- *errcode = MP_EOPNOTSUPP;
- return MP_STREAM_ERROR;
- }
- // no-operation
+ f_lseek(&self->fp, f_tell(&self->fp) + s->offset);
break;
case 2: // SEEK_END
diff --git a/tests/extmod/vfs_fat_fileio1.py b/tests/extmod/vfs_fat_fileio1.py
index d19df120b..8b9ff92eb 100644
--- a/tests/extmod/vfs_fat_fileio1.py
+++ b/tests/extmod/vfs_fat_fileio1.py
@@ -91,10 +91,8 @@ with open("foo_file.txt") as f2:
f2.seek(0, 1) # SEEK_CUR
print(f2.read(1))
- try:
- f2.seek(1, 1) # SEEK_END
- except OSError as e:
- print(e.args[0] == uerrno.EOPNOTSUPP)
+ f2.seek(2, 1) # SEEK_CUR
+ print(f2.read(1))
f2.seek(-2, 2) # SEEK_END
print(f2.read(1))
diff --git a/tests/extmod/vfs_fat_fileio1.py.exp b/tests/extmod/vfs_fat_fileio1.py.exp
index d777585cf..a66f07605 100644
--- a/tests/extmod/vfs_fat_fileio1.py.exp
+++ b/tests/extmod/vfs_fat_fileio1.py.exp
@@ -7,7 +7,7 @@ hello!world!
12
h
e
-True
+o
d
True
[('foo_dir', 16384, 0)]