rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
wa_walk.c File Reference

Walking the card. See wa_walk.h. More...

#include "wa_walk.h"
#include <string.h>

Functions

void wa_walk_begin (wa_walk_t *w, const wa_fs_t *fs)
 A walk of fs from its root; nothing is opened yet.
void wa_walk_end (wa_walk_t *w)
 Close every handle that is open; for a walk given up part way.
static wa_walk_ev_t finish (wa_walk_t *w, wa_walk_ev_t ev)
 End the walk with ev, every handle closed.
static bool name_ok (const char *s, size_t n)
 Whether a name read from the card can be served by its path.
static uint32_t join (wa_walk_t *w, uint32_t base, const char *name, size_t n)
 The path of name in the folder whose path is base bytes, into w->path.
wa_walk_ev_t wa_walk_next (wa_walk_t *w)
 The next event.

Detailed Description

Walking the card. See wa_walk.h.

SPDX-License-Identifier: MIT

Function Documentation

◆ finish()

wa_walk_ev_t finish ( wa_walk_t * w,
wa_walk_ev_t ev )
static

End the walk with ev, every handle closed.

Parameters
wthe walk
evEND, NO_CARD or ERROR
Returns
ev

◆ join()

uint32_t join ( wa_walk_t * w,
uint32_t base,
const char * name,
size_t n )
static

The path of name in the folder whose path is base bytes, into w->path.

Parameters
wthe walk
basebytes of the folder's path
namethe name
nits bytes
Returns
the path's bytes, or 0 when it is over WA_PATH_MAX

◆ name_ok()

bool name_ok ( const char * s,
size_t n )
static

Whether a name read from the card can be served by its path.

Parameters
sthe name
nits bytes
Returns
true for UTF-8 of 1 to WA_NAME_UNITS units, no separator, no control byte

◆ wa_walk_begin()

void wa_walk_begin ( wa_walk_t * w,
const wa_fs_t * fs )

A walk of fs from its root; nothing is opened yet.

Parameters
wthe walk
fsthe card

◆ wa_walk_end()

void wa_walk_end ( wa_walk_t * w)

Close every handle that is open; for a walk given up part way.

Parameters
wthe walk

◆ wa_walk_next()

wa_walk_ev_t wa_walk_next ( wa_walk_t * w)

The next event.

WA_WALK_DIR and WA_WALK_FILE carry path, and a file ent.size and ent.mtime; the root's WA_WALK_DIR has the path "".

Parameters
wthe walk
Returns
the event; after WA_WALK_END, NO_CARD or ERROR every call returns the same