Implement file system API and add shutdown functionality for desktop builds

This commit is contained in:
Lukas Höppner
2026-08-09 22:38:43 +02:00
parent 1654d366b2
commit 8e99fca404
13 changed files with 318 additions and 25 deletions
+39
View File
@@ -0,0 +1,39 @@
#ifndef NOVA64_FS_H
#define NOVA64_FS_H
#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>
/* ========================================================================== */
/* File System API */
/* ========================================================================== */
/**
* @brief Reads a file from the filesystem into a buffer.
* Supports drive identifiers: "SYS:" (internal system store),
* "EXA:" (cartridge slot 0), "EXB:" (cartridge slot 1), etc.
* @param file_path Null-terminated file path with drive identifier
* (e.g., "SYS:/init.wasm" or "EXA:/game.wasm").
* @param buffer Pointer to destination buffer where file contents will be
* copied.
* @param buffer_size Size in bytes of the destination buffer.
* @return True if file was successfully read into buffer, false on error
* (file not found, read error, or buffer too small).
* @note Uses the sd_read_sector callback from nova64_io_interface_t.
* The callback must be registered via nova64_init() before calling
* this function.
*/
bool nova64_read_file_to_buffer(const char *file_path, uint8_t *buffer,
size_t buffer_size);
/**
* @brief Gets the size of a file in the filesystem.
* @param file_path Null-terminated file path with drive identifier
* (e.g., "SYS:/init.wasm" or "EXA:/game.wasm").
* @return Size of the file in bytes on success, or -1 on error
* (file not found, read error, etc.).
*/
int32_t nova64_get_file_size(const char *file_path);
#endif // NOVA64_FS_H