libnx/nx/include/switch/runtime/devices/fs_dev.h
2018-01-11 21:38:12 +01:00

38 lines
1.3 KiB
C

/**
* @file fs_dev.h
* @brief FS driver.
*/
#pragma once
//NOTE: This is currently not usable.
#define FSDEV_DIRITER_MAGIC 0x66736476 /* "fsdv" */
/*! Open directory struct */
typedef struct
{
u32 magic; /*! "fsdv" */
FsDir fd;
ssize_t index; /*! Current entry index */
size_t size; /*! Current batch size */
FsDirectoryEntry entry_data[32]; /*! Temporary storage for reading entries */
} fsdev_dir_t;
/// Initializes the FS driver. Automatically initializes the sdmc device if accessible. If called again, sdmc mounting will be attempted again if it's not mounted.
Result fsdevInit(void);
/// Exits the FS driver. Any devices still mounted are unmounted.
Result fsdevExit(void);
/// Mounts the input fs with the specified device name. fsdev will handle closing the fs when required, including when fsdevMountDevice() fails.
/// Returns -1 when any errors occur.
int fsdevMountDevice(const char *name, FsFileSystem fs);
/// Unmounts the specified device.
int fsdevUnmountDevice(const char *name);
/// Uses fsFsCommit() with the specified device. This must be used after any savedata-write operations(not just file-write).
/// This is not used automatically at device unmount.
Result fsdevCommitDevice(const char *name);