stmhal, file: Seek to end of file if opened in 'a' mode.

This commit is contained in:
Damien George 2014-06-11 16:01:52 +01:00
parent b7572ad11b
commit 820896746c
1 changed files with 5 additions and 0 deletions

View File

@ -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]))); 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; return o;
} }