summaryrefslogtreecommitdiffstatshomepage
path: root/stmhal/file.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-06-11 16:01:52 +0100
committerDamien George <damien.p.george@gmail.com>2014-06-11 16:01:52 +0100
commit820896746c9935e0233b179d4a7601a3f2609763 (patch)
treebaac4ca18b27331f885babcee8d9e10bae230c92 /stmhal/file.c
parentb7572ad11b31d4e357139e877a0815ebd6ae515e (diff)
downloadmicropython-820896746c9935e0233b179d4a7601a3f2609763.tar.gz
micropython-820896746c9935e0233b179d4a7601a3f2609763.zip
stmhal, file: Seek to end of file if opened in 'a' mode.
Diffstat (limited to 'stmhal/file.c')
-rw-r--r--stmhal/file.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/stmhal/file.c b/stmhal/file.c
index fbaff879f4..a00c9a8f8f 100644
--- a/stmhal/file.c
+++ b/stmhal/file.c
@@ -202,6 +202,11 @@ STATIC mp_obj_t file_obj_make_new(mp_obj_t type, uint n_args, uint n_kw, const m
nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT((machine_int_t)fresult_to_errno_table[res])));
}
+ // for 'a' mode, we must begin at the end of the file
+ if ((mode & FA_OPEN_ALWAYS) != 0) {
+ f_lseek(&o->fp, f_size(&o->fp));
+ }
+
return o;
}