You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.4 KiB
51 lines
1.4 KiB
#pragma once
|
|
|
|
#include <stdbool.h>
|
|
#include <stddef.h>
|
|
#include "espfsformat.h"
|
|
#include "heatshrink_decoder.h"
|
|
|
|
typedef enum {
|
|
ESPFS_INIT_RESULT_OK,
|
|
ESPFS_INIT_RESULT_NO_IMAGE,
|
|
ESPFS_INIT_RESULT_BAD_ALIGN,
|
|
} EspFsInitResult;
|
|
|
|
typedef struct EspFsFile EspFsFile;
|
|
|
|
struct EspFsWalk {
|
|
uint32_t hpos;
|
|
};
|
|
typedef struct EspFsWalk EspFsWalk;
|
|
|
|
/**
|
|
* Read a file header
|
|
*
|
|
* @param[in] file - file to read
|
|
* @param[out] header - header is read here
|
|
* @return 0 = success
|
|
*/
|
|
int espFsFileReadHeader(const EspFsFile *file, EspFsHeader *header);
|
|
/** Init filesystem walk */
|
|
void espFsWalkInit(EspFsWalk *walk);
|
|
/**
|
|
* Advance in the filesystem walk
|
|
*
|
|
* header - the next file's header is read here
|
|
* namebuf - the name is read here
|
|
* filepos - the file header's pos is copied here, if not NULL
|
|
*/
|
|
bool espFsWalkNext(EspFsWalk *walk, EspFsHeader *header, char *namebuf, size_t namebuf_cap, uint32_t *filepos);
|
|
/** Open a file with header starting at the given position */
|
|
EspFsFile *espFsOpenAt(uint32_t hpos);
|
|
/**
|
|
* Open a file using an already read header and it's offset.
|
|
* This is the same function as espFsOpenAt, but avoids reading the header again if already read.
|
|
*/
|
|
EspFsFile *espFsOpenFromHeader(EspFsHeader *h, uint32_t hpos);
|
|
|
|
EspFsInitResult espFsInit();
|
|
EspFsFile *espFsOpen(const char *fileName);
|
|
int espFsFlags(EspFsFile *fh);
|
|
int espFsRead(EspFsFile *fh, uint8_t *buff, size_t len);
|
|
void espFsClose(EspFsFile *fh);
|
|
|