Small compatibility layer over the storage backends used by Noodle. More...
Macros | |
| #define | NOODLE_FS_NEEDS_LEADING_SLASH 1 |
| Whether the selected backend expects normalized paths to start with '/'. | |
| #define | NOODLE_MAX_FILENAME 20 |
| Maximum filename length copied by noodle_norm_filename(). | |
Functions | |
| void | noodle_copy_name (char *dst, size_t cap, const char *src) |
| Copy a C string into a bounded buffer with NUL-termination. | |
| const char * | noodle_norm_filename (const char *name) |
| Normalize a filename/path for the selected filesystem backend. | |
| NDL_File | noodle_fs_open_read (const char *path) |
| Open a file for reading using the selected backend. | |
| NDL_File | noodle_fs_open_write (const char *path) |
| Open a file for writing using the selected backend. | |
| bool | noodle_fs_remove (const char *path) |
| Remove a file using the selected backend. | |
| void | noodle_rewind_file (NDL_File &fi) |
| Rewind a file handle to position 0. | |
Small compatibility layer over the storage backends used by Noodle.
Noodle reads and writes model tensors through a tiny common API so the same higher-level code can run on SdFat, SD_MMC, FFat, LittleFS, or with storage disabled. This header selects the backend-specific includes and exposes:
Define exactly one backend macro before this header is included:
When using the main noodle.h entry point, noodle_config.h is included first and selects NOODLE_USE_SDFAT by default if no backend macro is set. If this header is included directly, the caller must define one backend macro first.
Arduino filesystem APIs such as SD_MMC, FFat, and LittleFS expect paths with a leading slash, for example "/w01.txt". SdFat commonly uses bare names, for example "w01.txt". noodle_norm_filename() applies this policy before open/remove calls.
| #define NOODLE_FS_NEEDS_LEADING_SLASH 1 |
Whether the selected backend expects normalized paths to start with '/'.
SdFat is treated as accepting bare filenames. Other real Arduino filesystem backends are normalized to slash-prefixed paths.
| #define NOODLE_MAX_FILENAME 20 |
Maximum filename length copied by noodle_norm_filename().
The limit applies to the input name characters, excluding any added leading slash and trailing NUL. Longer names are truncated by noodle_copy_name().
|
inline |
Copy a C string into a bounded buffer with NUL-termination.
If src is nullptr, dst is set to an empty string. If src is longer than the destination capacity, the result is truncated and still NUL-terminated.
| dst | Destination buffer. |
| cap | Destination capacity in bytes, including the trailing NUL. |
| src | Source C string. |
|
inline |
Open a file for reading using the selected backend.
The path is normalized with noodle_norm_filename() before opening. In NOODLE_USE_NONE mode this returns an invalid NDL_File.
| path | Filename or path. |
|
inline |
Open a file for writing using the selected backend.
The path is normalized with noodle_norm_filename() before opening. Existing SdFat files are truncated. Other backends use their FILE_WRITE mode. In NOODLE_USE_NONE mode this returns an invalid NDL_File.
| path | Filename or path. |
|
inline |
Remove a file using the selected backend.
The path is normalized with noodle_norm_filename() before removal.
| path | Filename or path. |
|
inline |
Normalize a filename/path for the selected filesystem backend.
SdFat paths are returned unchanged. For backends that require a leading slash, this function prepends '/' unless name already starts with one.
| name | Input filename or path, for example "w01.txt" or "/w01.txt". |
|
inline |
Rewind a file handle to position 0.
SdFat exposes seekSet(0), while Arduino File backends expose seek(0). In NOODLE_USE_NONE mode the handle is closed.
| fi | Open file handle to rewind. |