libnx
fs_dev.h
Go to the documentation of this file.
1 /**
2  * @file fs_dev.h
3  * @brief FS driver, using devoptab.
4  * @author yellows8
5  * @author mtheall
6  * @copyright libnx Authors
7  */
8 #pragma once
9 
10 #include <sys/types.h>
11 #include "../../services/fs.h"
12 
13 #define FSDEV_DIRITER_MAGIC 0x66736476 ///< "fsdv"
14 
15 /// Open directory struct
16 typedef struct
17 {
18  u32 magic; ///< "fsdv"
19  FsDir fd; ///< File descriptor
20  ssize_t index; ///< Current entry index
21  size_t size; ///< Current batch size
22  FsDirectoryEntry entry_data[32]; ///< Temporary storage for reading entries
23 } fsdev_dir_t;
24 
25 /// Initializes and mounts the sdmc device if accessible. Also initializes current working directory to point to the folder containing the path to the executable (argv[0]), if it is provided by the environment.
27 
28 /// Mounts the input fs with the specified device name. fsdev will handle closing the fs when required, including when fsdevMountDevice() fails.
29 /// Returns -1 when any errors occur.
30 int fsdevMountDevice(const char *name, FsFileSystem fs);
31 
32 /// Unmounts the specified device.
33 int fsdevUnmountDevice(const char *name);
34 
35 /// Uses fsFsCommit() with the specified device. This must be used after any savedata-write operations(not just file-write).
36 /// This is not used automatically at device unmount.
37 Result fsdevCommitDevice(const char *name);
38 
39 /// Returns the FsFileSystem for the default device (SD card), if mounted. Used internally by romfs_dev.
41 
42 /// Unmounts all devices and cleans up any resources used by the FS driver.
FsDir fd
File descriptor.
Definition: fs_dev.h:19
Result fsdevCommitDevice(const char *name)
Uses fsFsCommit() with the specified device.
ssize_t index
Current entry index.
Definition: fs_dev.h:20
size_t size
Current batch size.
Definition: fs_dev.h:21
FsFileSystem * fsdevGetDefaultFileSystem(void)
Returns the FsFileSystem for the default device (SD card), if mounted. Used internally by romfs_dev...
u32 Result
Function error code result type.
Definition: types.h:46
Result fsdevMountSdmc(void)
Initializes and mounts the sdmc device if accessible. Also initializes current working directory to p...
Result fsdevUnmountAll(void)
Unmounts all devices and cleans up any resources used by the FS driver.
uint32_t u32
32-bit unsigned integer.
Definition: types.h:23
int fsdevMountDevice(const char *name, FsFileSystem fs)
Mounts the input fs with the specified device name.
u32 magic
"fsdv"
Definition: fs_dev.h:18
Open directory struct.
Definition: fs_dev.h:16
Definition: fs.h:23
int fsdevUnmountDevice(const char *name)
Unmounts the specified device.
Definition: fs.h:31
Directory entry.
Definition: fs.h:52