rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
wa_walk.h
Go to the documentation of this file.
1
29
30#ifndef RCBENCH_WA_WALK_H
31#define RCBENCH_WA_WALK_H
32
33#include <stdbool.h>
34#include <stdint.h>
35
36#include "wa_text.h"
37
38#ifdef __cplusplus
39extern "C" {
40#endif
41
43#define WA_WALK_DEPTH 16u
44
45typedef struct {
46 char name[WA_NAME_BYTES];
47 bool dir;
48 uint64_t size;
49 int64_t mtime;
51
53typedef struct {
54 void *(*opendir)(void *ctx, const char *path);
56 int (*readdir)(void *ctx, void *dir, wa_dirent_t *out);
57 void (*closedir)(void *ctx, void *dir);
58 void *(*open)(void *ctx, const char *path);
60 int32_t (*read)(void *ctx, void *file, uint8_t *dst, uint32_t len);
61 void (*close)(void *ctx, void *file);
62 void *ctx;
65 bool (*stopped)(void *ctx);
66} wa_fs_t;
67
76
77typedef struct {
78 void *dir;
79 uint32_t len;
80 bool dirs;
82
84typedef struct {
85 const wa_fs_t *fs;
86 unsigned depth;
88 char path[WA_PATH_MAX + 1u];
90 unsigned long left_out;
91 bool started;
93 bool over;
94} wa_walk_t;
95
101void wa_walk_begin(wa_walk_t *w, const wa_fs_t *fs);
102
114
119void wa_walk_end(wa_walk_t *w);
120
121#ifdef __cplusplus
122}
123#endif
124
125#endif /* RCBENCH_WA_WALK_H */
Definition wa_walk.h:45
int64_t mtime
Definition wa_walk.h:49
uint64_t size
Definition wa_walk.h:48
Definition wa_walk.h:53
int(*) readdir(void *ctx, void *dir, wa_dirent_t *out)
Definition wa_walk.h:56
bool(*) stopped(void *ctx)
Whether the walk is to end now, asked before every entry; NULL never.
Definition wa_walk.h:65
int32_t(*) read(void *ctx, void *file, uint8_t *dst, uint32_t len)
Definition wa_walk.h:60
Definition wa_walk.h:77
void * dir
Definition wa_walk.h:78
bool dirs
Definition wa_walk.h:80
uint32_t len
Definition wa_walk.h:79
A walk under way.
Definition wa_walk.h:84
bool started
Definition wa_walk.h:91
char path[WA_PATH_MAX+1u]
Definition wa_walk.h:88
const wa_fs_t * fs
Definition wa_walk.h:85
bool over
Definition wa_walk.h:93
unsigned long left_out
Definition wa_walk.h:90
wa_dirent_t ent
Definition wa_walk.h:89
wa_walk_ev_t last
Definition wa_walk.h:92
unsigned depth
Definition wa_walk.h:86
wa_level_t lv[WA_WALK_DEPTH+1u]
Definition wa_walk.h:87
wa_walk_ev_t wa_walk_next(wa_walk_t *w)
The next event.
Definition wa_walk.c:89
void wa_walk_end(wa_walk_t *w)
Close every handle that is open; for a walk given up part way.
Definition wa_walk.c:18
#define WA_WALK_DEPTH
Definition wa_walk.h:43
wa_walk_ev_t
What wa_walk_next() hands out.
Definition wa_walk.h:69
@ WA_WALK_FILE
Definition wa_walk.h:71
@ WA_WALK_DIR
Definition wa_walk.h:70
@ WA_WALK_NO_CARD
Definition wa_walk.h:73
@ WA_WALK_END
Definition wa_walk.h:72
@ WA_WALK_ERROR
Definition wa_walk.h:74
void wa_walk_begin(wa_walk_t *w, const wa_fs_t *fs)
A walk of fs from its root; nothing is opened yet.
Definition wa_walk.c:12