espfs.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #ifndef ESPFS_H
  2. #define ESPFS_H
  3. #include "espfsformat.h"
  4. typedef enum {
  5. ESPFS_INIT_RESULT_OK,
  6. ESPFS_INIT_RESULT_NO_IMAGE,
  7. ESPFS_INIT_RESULT_BAD_ALIGN,
  8. } EspFsInitResult;
  9. // Only 1 MByte of the flash can be directly accessed with ESP8266
  10. // If flash size is >1 Mbyte, SDK API is required to retrieve flash content
  11. typedef enum {
  12. ESPFS_MEMORY, // read data directly from memory (fast, max 1 MByte)
  13. ESPFS_FLASH, // read data from flash using SDK API (no limit for the size)
  14. } EspFsSource;
  15. typedef struct EspFsFile EspFsFile;
  16. typedef struct EspFsContext EspFsContext;
  17. typedef struct {
  18. EspFsHeader header; // the header of the current file
  19. EspFsContext *ctx; // pointer to espfs context
  20. char name[256]; // the name of the current file
  21. char *position; // position of the iterator (pointer on the file system)
  22. } EspFsIterator;
  23. extern EspFsContext * espLinkCtx;
  24. extern EspFsContext * userPageCtx;
  25. EspFsInitResult espFsInit(EspFsContext *ctx, void *flashAddress, EspFsSource source);
  26. EspFsFile *espFsOpen(EspFsContext *ctx, char *fileName);
  27. int espFsIsValid(EspFsContext *ctx);
  28. int espFsFlags(EspFsFile *fh);
  29. int espFsRead(EspFsFile *fh, char *buff, int len);
  30. void espFsClose(EspFsFile *fh);
  31. void espFsIteratorInit(EspFsContext *ctx, EspFsIterator *iterator);
  32. int espFsIteratorNext(EspFsIterator *iterator);
  33. #endif