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.
42 lines
1.2 KiB
42 lines
1.2 KiB
2 years ago
|
#pragma once
|
||
|
|
||
|
#include <stdbool.h>
|
||
|
#include "espfsformat.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;
|
||
|
|
||
|
/** 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, char *buff, size_t len);
|
||
|
void espFsClose(EspFsFile *fh);
|