10 #if defined(__cplusplus)
14 #include "spiffs_config.h"
17 #define SPIFFS_ERR_NOT_MOUNTED -10000
18 #define SPIFFS_ERR_FULL -10001
19 #define SPIFFS_ERR_NOT_FOUND -10002
20 #define SPIFFS_ERR_END_OF_OBJECT -10003
21 #define SPIFFS_ERR_DELETED -10004
22 #define SPIFFS_ERR_NOT_FINALIZED -10005
23 #define SPIFFS_ERR_NOT_INDEX -10006
24 #define SPIFFS_ERR_OUT_OF_FILE_DESCS -10007
25 #define SPIFFS_ERR_FILE_CLOSED -10008
26 #define SPIFFS_ERR_FILE_DELETED -10009
27 #define SPIFFS_ERR_BAD_DESCRIPTOR -10010
28 #define SPIFFS_ERR_IS_INDEX -10011
29 #define SPIFFS_ERR_IS_FREE -10012
30 #define SPIFFS_ERR_INDEX_SPAN_MISMATCH -10013
31 #define SPIFFS_ERR_DATA_SPAN_MISMATCH -10014
32 #define SPIFFS_ERR_INDEX_REF_FREE -10015
33 #define SPIFFS_ERR_INDEX_REF_LU -10016
34 #define SPIFFS_ERR_INDEX_REF_INVALID -10017
35 #define SPIFFS_ERR_INDEX_FREE -10018
36 #define SPIFFS_ERR_INDEX_LU -10019
37 #define SPIFFS_ERR_INDEX_INVALID -10020
38 #define SPIFFS_ERR_NOT_WRITABLE -10021
39 #define SPIFFS_ERR_NOT_READABLE -10022
40 #define SPIFFS_ERR_CONFLICTING_NAME -10023
41 #define SPIFFS_ERR_NOT_CONFIGURED -10024
43 #define SPIFFS_ERR_NOT_A_FS -10025
44 #define SPIFFS_ERR_MOUNTED -10026
45 #define SPIFFS_ERR_ERASE_FAIL -10027
46 #define SPIFFS_ERR_MAGIC_NOT_POSSIBLE -10028
48 #define SPIFFS_ERR_NO_DELETED_BLOCKS -10029
50 #define SPIFFS_ERR_FILE_EXISTS -10030
52 #define SPIFFS_ERR_INTERNAL -10050
54 #define SPIFFS_ERR_TEST -10100
58 typedef s16_t spiffs_file;
60 typedef u16_t spiffs_flags;
62 typedef u16_t spiffs_mode;
64 typedef u8_t spiffs_obj_type;
66 #if SPIFFS_HAL_CALLBACK_EXTRA
70 typedef s32_t (*spiffs_read)(
struct spiffs_t *
fs, u32_t addr, u32_t size, u8_t *dst);
72 typedef s32_t (*spiffs_write)(
struct spiffs_t *fs, u32_t addr, u32_t size, u8_t *src);
74 typedef s32_t (*spiffs_erase)(
struct spiffs_t *fs, u32_t addr, u32_t size);
76 #else // SPIFFS_HAL_CALLBACK_EXTRA
79 typedef s32_t (*spiffs_read)(u32_t addr, u32_t size, u8_t *dst);
81 typedef s32_t (*spiffs_write)(u32_t addr, u32_t size, u8_t *src);
83 typedef s32_t (*spiffs_erase)(u32_t addr, u32_t size);
84 #endif // SPIFFS_HAL_CALLBACK_EXTRA
88 SPIFFS_CHECK_LOOKUP = 0,
95 SPIFFS_CHECK_PROGRESS = 0,
97 SPIFFS_CHECK_FIX_INDEX,
98 SPIFFS_CHECK_FIX_LOOKUP,
99 SPIFFS_CHECK_DELETE_ORPHANED_INDEX,
100 SPIFFS_CHECK_DELETE_PAGE,
101 SPIFFS_CHECK_DELETE_BAD_FILE,
102 } spiffs_check_report;
105 #if SPIFFS_HAL_CALLBACK_EXTRA
106 typedef void (*spiffs_check_callback)(
struct spiffs_t *fs, spiffs_check_type type, spiffs_check_report report,
107 u32_t arg1, u32_t arg2);
108 #else // SPIFFS_HAL_CALLBACK_EXTRA
109 typedef void (*spiffs_check_callback)(spiffs_check_type type, spiffs_check_report report,
110 u32_t arg1, u32_t arg2);
111 #endif // SPIFFS_HAL_CALLBACK_EXTRA
114 #define SPIFFS_DBG(...) \
117 #ifndef SPIFFS_GC_DBG
118 #define SPIFFS_GC_DBG(...) printf(__VA_ARGS__)
120 #ifndef SPIFFS_CACHE_DBG
121 #define SPIFFS_CACHE_DBG(...) printf(__VA_ARGS__)
123 #ifndef SPIFFS_CHECK_DBG
124 #define SPIFFS_CHECK_DBG(...) printf(__VA_ARGS__)
128 #define SPIFFS_APPEND (1<<0)
130 #define SPIFFS_TRUNC (1<<1)
132 #define SPIFFS_CREAT (1<<2)
134 #define SPIFFS_RDONLY (1<<3)
136 #define SPIFFS_WRONLY (1<<4)
138 #define SPIFFS_RDWR (SPIFFS_RDONLY | SPIFFS_WRONLY)
140 #define SPIFFS_DIRECT (1<<5)
142 #define SPIFFS_EXCL (1<<6)
144 #define SPIFFS_SEEK_SET (0)
145 #define SPIFFS_SEEK_CUR (1)
146 #define SPIFFS_SEEK_END (2)
148 #define SPIFFS_TYPE_FILE (1)
149 #define SPIFFS_TYPE_DIR (2)
150 #define SPIFFS_TYPE_HARD_LINK (3)
151 #define SPIFFS_TYPE_SOFT_LINK (4)
154 #define SPIFFS_LOCK(fs)
157 #ifndef SPIFFS_UNLOCK
158 #define SPIFFS_UNLOCK(fs)
171 #if SPIFFS_SINGLETON == 0
189 #if SPIFFS_FILEHDL_OFFSET
242 #if SPIFFS_CACHE_STATS
264 u8_t name[SPIFFS_OBJ_NAME_LEN];
269 u8_t
name[SPIFFS_OBJ_NAME_LEN];
299 u8_t *fd_space, u32_t fd_space_size,
300 void *cache, u32_t cache_size,
301 spiffs_check_callback check_cb_f);
308 void SPIFFS_unmount(
spiffs *fs);
316 s32_t SPIFFS_creat(
spiffs *fs,
const char *path, spiffs_mode mode);
327 spiffs_file SPIFFS_open(
spiffs *fs,
const char *path, spiffs_flags flags, spiffs_mode mode);
343 spiffs_file SPIFFS_open_by_dirent(
spiffs *fs,
struct spiffs_dirent *e, spiffs_flags flags, spiffs_mode mode);
353 s32_t SPIFFS_read(
spiffs *fs, spiffs_file fh,
void *buf, s32_t len);
363 s32_t SPIFFS_write(
spiffs *fs, spiffs_file fh,
void *buf, s32_t len);
375 s32_t SPIFFS_lseek(
spiffs *fs, spiffs_file fh, s32_t offs,
int whence);
382 s32_t SPIFFS_remove(
spiffs *fs,
const char *path);
389 s32_t SPIFFS_fremove(
spiffs *fs, spiffs_file fh);
412 s32_t SPIFFS_fflush(
spiffs *fs, spiffs_file fh);
419 s32_t SPIFFS_close(
spiffs *fs, spiffs_file fh);
427 s32_t SPIFFS_rename(
spiffs *fs,
const char *old,
const char *newPath);
433 s32_t SPIFFS_errno(
spiffs *fs);
439 void SPIFFS_clearerr(
spiffs *fs);
470 s32_t SPIFFS_check(
spiffs *fs);
484 s32_t SPIFFS_info(
spiffs *fs, u32_t *total, u32_t *used);
499 s32_t SPIFFS_format(
spiffs *fs);
505 u8_t SPIFFS_mounted(
spiffs *fs);
530 s32_t SPIFFS_gc_quick(
spiffs *fs, u16_t max_free_pages);
549 s32_t SPIFFS_gc(
spiffs *fs, u32_t size);
556 s32_t SPIFFS_eof(
spiffs *fs, spiffs_file fh);
563 s32_t SPIFFS_tell(
spiffs *fs, spiffs_file fh);
565 #if SPIFFS_TEST_VISUALISATION
570 s32_t SPIFFS_vis(
spiffs *fs);
573 #if SPIFFS_BUFFER_HELP
578 u32_t SPIFFS_buffer_bytes_for_filedescs(
spiffs *fs, u32_t num_descs);
585 u32_t SPIFFS_buffer_bytes_for_cache(
spiffs *fs, u32_t num_pages);
591 #if defined(__cplusplus)
u32_t size
Definition: spiffs.h:271
spiffs * fs
Definition: spiffs.h:276
u32_t free_blocks
Definition: spiffs.h:223
u8_t * lu_work
Definition: spiffs.h:211
spiffs_obj_id max_erase_count
Definition: spiffs.h:231
u32_t log_block_size
Definition: spiffs.h:183
u8_t name[(32)]
Definition: spiffs.h:269
spiffs_block_ix block
Definition: spiffs.h:277
void * user_data
Definition: spiffs.h:254
u32_t fd_count
Definition: spiffs.h:217
int cursor_obj_lu_entry
Definition: spiffs.h:208
u8_t * work
Definition: spiffs.h:213
spiffs_write hal_write_f
Definition: spiffs.h:168
Definition: ESP8266WebServer.h:55
u32_t cache_size
Definition: spiffs.h:241
spiffs_obj_type type
Definition: spiffs.h:270
u32_t stats_p_deleted
Definition: spiffs.h:227
spiffs_erase hal_erase_f
Definition: spiffs.h:170
spiffs_obj_type type
Definition: spiffs.h:263
u32_t phys_addr
Definition: spiffs.h:176
u8_t cleaning
Definition: spiffs.h:229
spiffs_check_callback check_cb_f
Definition: spiffs.h:249
spiffs_page_ix pix
Definition: spiffs.h:272
spiffs_config cfg
Definition: spiffs.h:197
u8_t * fd_space
Definition: spiffs.h:215
u32_t size
Definition: spiffs.h:262
spiffs_block_ix cursor_block_ix
Definition: spiffs.h:206
u32_t phys_erase_block
Definition: spiffs.h:178
u32_t stats_p_allocated
Definition: spiffs.h:225
u32_t log_page_size
Definition: spiffs.h:186
s32_t err_code
Definition: spiffs.h:220
spiffs_block_ix free_cursor_block_ix
Definition: spiffs.h:202
int free_cursor_obj_lu_entry
Definition: spiffs.h:204
u8_t mounted
Definition: spiffs.h:252
spiffs_read hal_read_f
Definition: spiffs.h:166
void * cache
Definition: spiffs.h:239
u32_t phys_size
Definition: spiffs.h:173
u32_t config_magic
Definition: spiffs.h:256
int entry
Definition: spiffs.h:278
spiffs_obj_id obj_id
Definition: spiffs.h:261
u32_t block_count
Definition: spiffs.h:199
spiffs_obj_id obj_id
Definition: spiffs.h:268