Lines Matching refs:file_p

57 lv_fs_res_t lv_fs_open(lv_fs_file_t * file_p, const char * path, lv_fs_mode_t mode)  in lv_fs_open()  argument
91 file_p->drv = drv; in lv_fs_open()
92 file_p->file_d = file_d; in lv_fs_open()
95 file_p->cache = lv_mem_alloc(sizeof(lv_fs_file_cache_t)); in lv_fs_open()
96 LV_ASSERT_MALLOC(file_p->cache); in lv_fs_open()
97 lv_memset_00(file_p->cache, sizeof(lv_fs_file_cache_t)); in lv_fs_open()
98 file_p->cache->start = UINT32_MAX; /*Set an invalid range by default*/ in lv_fs_open()
99 file_p->cache->end = UINT32_MAX - 1; in lv_fs_open()
105 lv_fs_res_t lv_fs_close(lv_fs_file_t * file_p) in lv_fs_close() argument
107 if(file_p->drv == NULL) { in lv_fs_close()
111 if(file_p->drv->close_cb == NULL) { in lv_fs_close()
115 lv_fs_res_t res = file_p->drv->close_cb(file_p->drv, file_p->file_d); in lv_fs_close()
117 if(file_p->drv->cache_size && file_p->cache) { in lv_fs_close()
118 if(file_p->cache->buffer) { in lv_fs_close()
119 lv_mem_free(file_p->cache->buffer); in lv_fs_close()
122 lv_mem_free(file_p->cache); in lv_fs_close()
125 file_p->file_d = NULL; in lv_fs_close()
126 file_p->drv = NULL; in lv_fs_close()
127 file_p->cache = NULL; in lv_fs_close()
132 static lv_fs_res_t lv_fs_read_cached(lv_fs_file_t * file_p, char * buf, uint32_t btr, uint32_t * br) in lv_fs_read_cached() argument
135 uint32_t file_position = file_p->cache->file_position; in lv_fs_read_cached()
136 uint32_t start = file_p->cache->start; in lv_fs_read_cached()
137 uint32_t end = file_p->cache->end; in lv_fs_read_cached()
138 char * buffer = file_p->cache->buffer; in lv_fs_read_cached()
139 uint16_t buffer_size = file_p->drv->cache_size; in lv_fs_read_cached()
158 … res = file_p->drv->read_cb(file_p->drv, file_p->file_d, (void *)(buf + buffer_remaining_length), in lv_fs_read_cached()
163 …res = file_p->drv->read_cb(file_p->drv, file_p->file_d, (void *)buffer, buffer_size, &bytes_read_t… in lv_fs_read_cached()
164 file_p->cache->start = file_p->cache->end; in lv_fs_read_cached()
165 file_p->cache->end = file_p->cache->start + bytes_read_to_buffer; in lv_fs_read_cached()
177 res = file_p->drv->read_cb(file_p->drv, file_p->file_d, (void *)buf, btr, br); in lv_fs_read_cached()
182 file_p->cache->buffer = lv_mem_alloc(buffer_size); in lv_fs_read_cached()
183 LV_ASSERT_MALLOC(file_p->cache->buffer); in lv_fs_read_cached()
184 buffer = file_p->cache->buffer; in lv_fs_read_cached()
188 …res = file_p->drv->read_cb(file_p->drv, file_p->file_d, (void *)buffer, buffer_size, &bytes_read_t… in lv_fs_read_cached()
189 file_p->cache->start = file_position; in lv_fs_read_cached()
190 file_p->cache->end = file_p->cache->start + bytes_read_to_buffer; in lv_fs_read_cached()
199 file_p->cache->file_position += *br; in lv_fs_read_cached()
205 lv_fs_res_t lv_fs_read(lv_fs_file_t * file_p, void * buf, uint32_t btr, uint32_t * br) in lv_fs_read() argument
208 if(file_p->drv == NULL) return LV_FS_RES_INV_PARAM; in lv_fs_read()
209 if(file_p->drv->read_cb == NULL) return LV_FS_RES_NOT_IMP; in lv_fs_read()
214 if(file_p->drv->cache_size) { in lv_fs_read()
215 res = lv_fs_read_cached(file_p, (char *)buf, btr, &br_tmp); in lv_fs_read()
218 res = file_p->drv->read_cb(file_p->drv, file_p->file_d, buf, btr, &br_tmp); in lv_fs_read()
226 lv_fs_res_t lv_fs_write(lv_fs_file_t * file_p, const void * buf, uint32_t btw, uint32_t * bw) in lv_fs_write() argument
230 if(file_p->drv == NULL) { in lv_fs_write()
234 if(file_p->drv->write_cb == NULL) { in lv_fs_write()
239 lv_fs_res_t res = file_p->drv->write_cb(file_p->drv, file_p->file_d, buf, btw, &bw_tmp); in lv_fs_write()
245 lv_fs_res_t lv_fs_seek(lv_fs_file_t * file_p, uint32_t pos, lv_fs_whence_t whence) in lv_fs_seek() argument
247 if(file_p->drv == NULL) { in lv_fs_seek()
251 if(file_p->drv->seek_cb == NULL) { in lv_fs_seek()
256 if(file_p->drv->cache_size) { in lv_fs_seek()
259 file_p->cache->file_position = pos; in lv_fs_seek()
262 …if(file_p->cache->file_position < file_p->cache->start || file_p->cache->file_position > file_p->c… in lv_fs_seek()
263 …res = file_p->drv->seek_cb(file_p->drv, file_p->file_d, file_p->cache->file_position, LV_FS_SEEK_S… in lv_fs_seek()
269 file_p->cache->file_position += pos; in lv_fs_seek()
272 …if(file_p->cache->file_position < file_p->cache->start || file_p->cache->file_position > file_p->c… in lv_fs_seek()
273 …res = file_p->drv->seek_cb(file_p->drv, file_p->file_d, file_p->cache->file_position, LV_FS_SEEK_S… in lv_fs_seek()
280 res = file_p->drv->seek_cb(file_p->drv, file_p->file_d, pos, whence); in lv_fs_seek()
283 res = file_p->drv->tell_cb(file_p->drv, file_p->file_d, &tmp_position); in lv_fs_seek()
286 file_p->cache->file_position = tmp_position; in lv_fs_seek()
294 res = file_p->drv->seek_cb(file_p->drv, file_p->file_d, pos, whence); in lv_fs_seek()
300 lv_fs_res_t lv_fs_tell(lv_fs_file_t * file_p, uint32_t * pos) in lv_fs_tell() argument
302 if(file_p->drv == NULL) { in lv_fs_tell()
307 if(file_p->drv->tell_cb == NULL) { in lv_fs_tell()
313 if(file_p->drv->cache_size) { in lv_fs_tell()
314 *pos = file_p->cache->file_position; in lv_fs_tell()
318 res = file_p->drv->tell_cb(file_p->drv, file_p->file_d, pos); in lv_fs_tell()