libnds
Loading...
Searching...
No Matches
Data Structures | Macros | Functions
device_io.h File Reference

Support for custom user-implemented filesystems. More...

#include <dirent.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/fcntl.h>
#include <sys/stat.h>
#include <sys/statvfs.h>
#include <sys/time.h>
#include <sys/times.h>
#include <sys/unistd.h>
#include <time.h>
#include <unistd.h>
#include <utime.h>

Data Structures

struct  device_io_t
 This struct defines the interface with the user-provided device. More...
 

Macros

#define DEVICE_IO_MAX_DEVICES   5
 Maximum number of devices that can be defined by the user.
 
#define DEVICE_IO_MAX_DRIVE_NAME_LENGTH   20
 This is the maximum length of a device I/O drive name.
 

Functions

int deviceIoAdd (const device_io_t *dev)
 Adds a new device.
 
const device_io_tdeviceIoGetFromIndex (int index)
 Returns the device interface at the specified index.
 
int deviceIoGetIndexFromDrive (const char *drive)
 Returns the device index that corresponds to the specified drive name.
 
int deviceIoRemove (int index)
 Removes the device at the specified device index.
 

Detailed Description

Support for custom user-implemented filesystems.

By default, libnds supports the NitroFS and FAT filesystems (DLDI, DSi SD and DSi NAND). The functions in this module allow the developer to define additional filesystems that can be accessed with the standard C functions (like fopen() or stat()).

Function Documentation

◆ deviceIoAdd()

int deviceIoAdd ( const device_io_t dev)

Adds a new device.

Parameters
devThe device to be added.
Returns
A device index on success, a negative number on error.

◆ deviceIoGetFromIndex()

const device_io_t * deviceIoGetFromIndex ( int  index)

Returns the device interface at the specified index.

Parameters
indexThe device index.
Returns
The device interface struct or NULL if it doesn't exist.

◆ deviceIoGetIndexFromDrive()

int deviceIoGetIndexFromDrive ( const char *  drive)

Returns the device index that corresponds to the specified drive name.

Parameters
driveThe drive name without colon or slash (for example, "nitro" or "fat").
Returns
The index that corresponds to the specified drive. If it doesn't correspond to any valid drive, it returns the index of the device active currently. If no device is active, it returns -1.

◆ deviceIoRemove()

int deviceIoRemove ( int  index)

Removes the device at the specified device index.

Parameters
indexThe index of the device to remove (the one returned by deviceIoAdd()).
Returns
On success, 0. On error, a negative number.