libnds
Loading...
Searching...
No Matches
Functions
filesystem.h File Reference

NitroFS filesystem embedded in a NDS ROM. More...

#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <nds/ndstypes.h>

Functions

bool nitroFSExit (void)
 Exits NitroFS.
 
WARN_UNUSED_RESULT FILE * nitroFSFopenById (uint16_t id, const char *mode)
 Open a NitroFS file directly by its FAT offset ID.
 
WARN_UNUSED_RESULT bool nitroFSInit (const char *basepath)
 Initializes NitroFS.
 
int nitroFSInitLookupCache (uint32_t max_buffer_size)
 This function initializes a NitroFS lookup cache.
 
int nitroFSOpenById (uint16_t id)
 Open a NitroFS file descriptor directly by its FAT offset ID.
 

Detailed Description

NitroFS filesystem embedded in a NDS ROM.

Function Documentation

◆ nitroFSExit()

bool nitroFSExit ( void  )

Exits NitroFS.

Returns
It returns true on success, false on error. If NitroFS hadn't been initialized before, it will also return true.

◆ nitroFSFopenById()

WARN_UNUSED_RESULT FILE * nitroFSFopenById ( uint16_t  id,
const char *  mode 
)

Open a NitroFS file directly by its FAT offset ID.

This FAT offset ID can be sourced from functions like

See also
stat,
fstat or
readdir - it is equivalent to the st_ino/d_ino value.

In all other functions, this file behaves identically to one sourced from

See also
fopen , and should be closed likewise.
Parameters
idThe FAT offset ID of the file (0x0000..0xEFFF).
modeThe file open mode. Only "r" and "rb" are supported.
Returns
A valid file pointer; NULL on error.

◆ nitroFSInit()

WARN_UNUSED_RESULT bool nitroFSInit ( const char *  basepath)

Initializes NitroFS.

If basepath or argv[0] is provided, an attempt to read the file system using DLDI will be made first. If that fails, the official cartridge protocol will be used instead.

Parameters
basepathThe .nds file path - NULL to auto-detect.
Returns
It returns true on success, false on error.

◆ nitroFSInitLookupCache()

int nitroFSInitLookupCache ( uint32_t  max_buffer_size)

This function initializes a NitroFS lookup cache.

This lookup cache allows avoiding expensive SD card lookups for large and/or backwards seeks, at the expensive of RAM usage.

This function will return 0 on non-DLDI/SD NitroFS accesses, as lookup caches are unnecessary in these situations.

Parameters
max_buffer_sizeThe maximum buffer size, in bytes.
Returns
0 if the initialization was successful, a non-zero value on error.

◆ nitroFSOpenById()

int nitroFSOpenById ( uint16_t  id)

Open a NitroFS file descriptor directly by its FAT offset ID.

This FAT offset ID can be sourced from functions like

See also
stat,
fstat or
readdir - it is equivalent to the st_ino/d_ino value.

In all other functions, this file descriptor behaves identically to one sourced from

See also
open , and should be closed likewise.
Parameters
idThe FAT offset ID of the file (0x0000..0xEFFF).
Returns
A valid file descriptor; -1 on error.