Added high level functions for reading file and returning file size.

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
Pol Henarejos 2022-05-24 00:18:43 +02:00
parent d19429cb84
commit 5e2fc081f1
No known key found for this signature in database
GPG key ID: C0095B7870A4CCD3
2 changed files with 14 additions and 0 deletions

View file

@ -247,6 +247,18 @@ uint8_t file_read_uint8(const uint8_t *addr) {
return flash_read_uint8((uintptr_t)addr);
}
uint8_t *file_get_data(const file_t *tf) {
if (!tf || !tf->data)
return NULL;
return file_read(tf->data+sizeof(uint16_t));
}
uint16_t file_get_size(const file_t *tf) {
if (!tf || !tf->data)
return 0;
return file_read_uint16(tf->data);
}
file_t *search_dynamic_file(uint16_t fid) {
for (int i = 0; i < dynamic_files; i++) {
if (dynamic_file[i].fid == fid)

View file

@ -106,6 +106,8 @@ extern file_t file_entries[];
extern uint8_t *file_read(const uint8_t *addr);
extern uint16_t file_read_uint16(const uint8_t *addr);
extern uint8_t file_read_uint8(const uint8_t *addr);
extern uint8_t *file_get_data(const file_t *tf);
extern uint16_t file_get_size(const file_t *tf);
extern file_t *file_new(uint16_t);
file_t *get_parent(file_t *f);