2018-04-14 05:28:45 -03:00
|
|
|
/*
|
|
|
|
implement a file store for embedded firmware images
|
|
|
|
*/
|
2019-05-20 11:57:43 -03:00
|
|
|
#pragma once
|
2018-04-14 05:28:45 -03:00
|
|
|
|
|
|
|
#include <AP_HAL/AP_HAL.h>
|
|
|
|
|
|
|
|
class AP_ROMFS {
|
|
|
|
public:
|
2018-07-09 03:28:28 -03:00
|
|
|
// find a file and de-compress, assumning gzip format. The
|
|
|
|
// decompressed data will be allocated with malloc(). You must
|
2019-10-23 06:54:32 -03:00
|
|
|
// call AP_ROMFS::free() on the return value after use. The next byte after
|
2018-10-29 19:17:12 -03:00
|
|
|
// the file data is guaranteed to be null.
|
2019-10-23 06:54:32 -03:00
|
|
|
static const uint8_t *find_decompress(const char *name, uint32_t &size);
|
|
|
|
|
|
|
|
// free returned data
|
|
|
|
static void free(const uint8_t *data);
|
|
|
|
|
2020-03-06 20:53:39 -04:00
|
|
|
/*
|
|
|
|
directory listing interface. Start with ofs=0. Returns pathnames
|
|
|
|
that match dirname prefix. Ends with nullptr return when no more
|
|
|
|
files found
|
|
|
|
*/
|
|
|
|
static const char *dir_list(const char *dirname, uint16_t &ofs);
|
|
|
|
|
2018-07-09 03:28:28 -03:00
|
|
|
private:
|
2018-04-14 05:28:45 -03:00
|
|
|
// find an embedded file
|
|
|
|
static const uint8_t *find_file(const char *name, uint32_t &size);
|
|
|
|
|
|
|
|
struct embedded_file {
|
|
|
|
const char *filename;
|
|
|
|
uint32_t size;
|
|
|
|
const uint8_t *contents;
|
|
|
|
};
|
|
|
|
static const struct embedded_file files[];
|
|
|
|
};
|