From 820896746c9935e0233b179d4a7601a3f2609763 Mon Sep 17 00:00:00 2001 From: Damien George Date: Wed, 11 Jun 2014 16:01:52 +0100 Subject: [PATCH] stmhal, file: Seek to end of file if opened in 'a' mode. --- stmhal/file.c | 5 +++++ 1 file changed, 5 insertions(+) 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; }