mirror of
https://github.com/lvgl/lvgl.git
synced 2024-11-28 04:03:45 +08:00
fix(fs): seek fs brfore writing data to file (#4859)
Signed-off-by: wangxuedong <wangxuedong@xiaomi.com>
This commit is contained in:
parent
990fbc8cdf
commit
b587fd78c4
@ -280,10 +280,21 @@ lv_fs_res_t lv_fs_write(lv_fs_file_t * file_p, const void * buf, uint32_t btw, u
|
||||
return LV_FS_RES_NOT_IMP;
|
||||
}
|
||||
|
||||
lv_fs_res_t res = LV_FS_RES_OK;
|
||||
|
||||
/*Need to do FS seek before writing data to FS*/
|
||||
if(file_p->drv->cache_size) {
|
||||
res = file_p->drv->seek_cb(file_p->drv, file_p->file_d, file_p->cache->file_position, LV_FS_SEEK_SET);
|
||||
if(res != LV_FS_RES_OK) return res;
|
||||
}
|
||||
|
||||
uint32_t bw_tmp = 0;
|
||||
lv_fs_res_t res = file_p->drv->write_cb(file_p->drv, file_p->file_d, buf, btw, &bw_tmp);
|
||||
res = file_p->drv->write_cb(file_p->drv, file_p->file_d, buf, btw, &bw_tmp);
|
||||
if(bw != NULL) *bw = bw_tmp;
|
||||
|
||||
if(file_p->drv->cache_size && res == LV_FS_RES_OK)
|
||||
file_p->cache->file_position += bw_tmp;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user