27#ifndef DETERMINISTICESPASYNCWEBSERVER_WAL_FS_H
28#define DETERMINISTICESPASYNCWEBSERVER_WAL_FS_H
32#if DETWS_ENABLE_WAL && defined(ARDUINO)
38namespace detws_wal_fs_detail
40inline size_t fs_read(
void *ctx, uint64_t off, uint8_t *buf,
size_t len)
42 fs::File *f = (fs::File *)ctx;
43 if (!f->seek((uint32_t)off))
45 return f->read(buf, len);
47inline size_t fs_write(
void *ctx, uint64_t off,
const uint8_t *buf,
size_t len)
49 fs::File *f = (fs::File *)ctx;
50 if (!f->seek((uint32_t)off))
52 return f->write(buf, len);
54inline bool fs_sync(
void *ctx)
56 ((fs::File *)ctx)->flush();
65inline bool wal_fs_prealloc(fs::FS &fsys,
const char *path, uint64_t size)
67 if (fsys.exists(path))
69 fs::File ex = fsys.open(path,
"r");
70 uint64_t have = ex ? (uint64_t)ex.size() : 0;
76 fs::File f = fsys.open(path,
"w");
80 memset(z, 0,
sizeof(z));
85 size_t n = left <
sizeof(z) ? (
size_t)left :
sizeof(z);
86 if (f.write(z, n) != n)
102inline WalDev wal_fs_dev(fs::File *f, uint64_t size)
105 d.read = detws_wal_fs_detail::fs_read;
106 d.write = detws_wal_fs_detail::fs_write;
107 d.sync = detws_wal_fs_detail::fs_sync;
User-facing configuration for DeterministicESPAsyncWebServer.
Durable write-ahead store: A/B superblock + checkpoint over a block-device seam (DETWS_ENABLE_WAL).