Swadge 2024 2.0.0
APIs to develop games for the Magfest Swadge
Loading...
Searching...
No Matches
cnfs.c File Reference

Functions

bool initCnfs (void)
 Initialize the CNFS file system. This is used to store assets like WSGs and fonts.
 
bool deinitCnfs (void)
 De-initialize the CNFS file system (right now a noop)
 
const uint8_t * cnfsGetFile (const char *fname, size_t *flen)
 Get a pointer to a file, without needing to read it. Same rules that apply to cnfsGetFile, and under the hood, cnfsGetFile uses this function.
 
uint8_t * cnfsReadFile (const char *fname, size_t *outsize, bool readToSpiRam)
 Read a file from CNFS into an output array. Files that are in the assets_image folder before compilation and flashing will automatically be included in the firmware.
 

Function Documentation

◆ initCnfs()

bool initCnfs ( void )

Initialize the CNFS file system. This is used to store assets like WSGs and fonts.

Returns
true if CNFS was initialized and can be used, false if it failed

◆ deinitCnfs()

bool deinitCnfs ( void )

De-initialize the CNFS file system (right now a noop)

Returns
true if de-initialize ok, false if it was not

◆ cnfsGetFile()

const uint8_t * cnfsGetFile ( const char * fname,
size_t * flen )

Get a pointer to a file, without needing to read it. Same rules that apply to cnfsGetFile, and under the hood, cnfsGetFile uses this function.

Parameters
fnameThe name of the file to find.
flenA pointer to a size_t to return the size of the file.
Returns
A pointer to the read data if successful, or NULL if there is a failure Do not free this pointer. It is pointing to flash.

◆ cnfsReadFile()

uint8_t * cnfsReadFile ( const char * fname,
size_t * outsize,
bool readToSpiRam )

Read a file from CNFS into an output array. Files that are in the assets_image folder before compilation and flashing will automatically be included in the firmware.

Parameters
fnameThe name of the file to load
outsizeA pointer to a size_t to return how much data was read
readToSpiRamtrue to use SPI RAM, false to use normal RAM
Returns
A pointer to the read data if successful, or NULL if there is a failure This data must be freed when done