Skip to content

Commit 8208967

Browse files
committed
stmhal, file: Seek to end of file if opened in 'a' mode.
1 parent b7572ad commit 8208967

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

stmhal/file.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,11 @@ STATIC mp_obj_t file_obj_make_new(mp_obj_t type, uint n_args, uint n_kw, const m
202202
nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT((machine_int_t)fresult_to_errno_table[res])));
203203
}
204204

205+
// for 'a' mode, we must begin at the end of the file
206+
if ((mode & FA_OPEN_ALWAYS) != 0) {
207+
f_lseek(&o->fp, f_size(&o->fp));
208+
}
209+
205210
return o;
206211
}
207212

0 commit comments

Comments
 (0)