|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Derive an on-card file name from a source book path (long-name capable). More...
#include <stddef.h>#include <stdint.h>#include <string.h>Go to the source code of this file.
Enumerations | |
| enum | mkbookimg_name_limit_t : uint32_t { k_mkbookimg_name_cap = 256U } |
| Bound on a derived on-card file name. More... | |
Functions | |
| static const char * | mkbookimg_basename (const char *path) |
Return the basename of path: the run after its last '/'. | |
| static bool | mkbookimg_dest_name (const char *path, char *out, size_t cap) |
Derive the on-card destination name for a source book path. | |
Derive an on-card file name from a source book path (long-name capable).
mkbookimg packs each input book onto the FAT card under a HUMAN-READABLE name: the source file's own basename, stored verbatim now that ra8_fs writes VFAT long names (#600). Before that landed the tool emitted BOOK01, BOOK02, ... under a forced 8.3 extension and threw the real name away (#633 removed that workaround).
This header is the pure, board-free name derivation the tool and its host round-trip test both call, so the test exercises the SAME logic the packer ships rather than a copy of it.
Definition in file mkbookimg_names.h.
| enum mkbookimg_name_limit_t : uint32_t |
Bound on a derived on-card file name.
The buffer must hold the widest VFAT long name ra8_fs will file (247 characters) plus a NUL, so 256 clears it with headroom while keeping the derivation on a fixed, statically-bounded buffer.
| Enumerator | |
|---|---|
| k_mkbookimg_name_cap | Destination-name buffer bytes incl. NUL (>= FAT 247 + 1). |
Definition at line 34 of file mkbookimg_names.h.
|
inlinestatic |
Return the basename of path: the run after its last '/'.
Scans path once for the final path separator and returns a pointer just past it, so content/library/Meditations.rabook yields Meditations.rabook and a already-bare name is returned unchanged. Only '/' is treated as a separator (the tool takes POSIX host paths on its command line).
| [in] | path | NUL-terminated source path (non-NULL). |
path at the first character after the last '/', or path itself when it contains no separator. | non-NULL | Always a valid pointer within path (never past its NUL). |
path is non-NULL and NUL-terminated. path is a host filesystem path (separators are '/'). path; no bytes are copied or modified. path ends in '/'.Definition at line 61 of file mkbookimg_names.h.
Referenced by internal_duplicate_name(), and mkbookimg_dest_name().
|
inlinestatic |
Derive the on-card destination name for a source book path.
Copies the source's basename (mkbookimg_basename) verbatim into out and NUL-terminates it, so the name the caller sees on the card is the name they packed. The copy is rejected – rather than truncated – when the basename is empty or does not fit cap, so a name is either filed in full or refused.
| [in] | path | Source path on the host (non-NULL, NUL-terminated). |
| [out] | out | Destination-name buffer; receives the NUL-terminated name. |
| [in] | cap | Capacity of out in bytes (> 0; use k_mkbookimg_name_cap). |
| true | A non-empty basename that fit cap was written and terminated. |
| false | path / out is NULL, cap is 0, the basename is empty, or it does not fit cap (nothing usable is left in out). |
path is non-NULL and NUL-terminated. out points at cap writable bytes. out holds the basename of path including its terminator. out is not relied upon (no truncated name is filed).out. Definition at line 99 of file mkbookimg_names.h.
References memcpy(), mkbookimg_basename(), and strlen().
Referenced by internal_write_books().