mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-21 20:42:44 +02:00
Updated fs_dev.h comments, etc. Fixed _fsdevUnmountDeviceStruct(). Added fsdevCommitDevice(). Check whether sdmc is already mounted in fsdevInit().
This commit is contained in:
parent
0c5efe5f9c
commit
7da25ba40f
@ -18,10 +18,10 @@ typedef struct
|
||||
FsDirectoryEntry entry_data[32]; /*! Temporary storage for reading entries */
|
||||
} fsdev_dir_t;
|
||||
|
||||
/// Initializes the FS driver.
|
||||
/// 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.
|
||||
/// 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.
|
||||
@ -31,3 +31,7 @@ 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);
|
||||
|
||||
|
@ -328,14 +328,15 @@ static int _fsdevUnmountDeviceStruct(fsdev_fsdevice *device)
|
||||
RemoveDevice(name);
|
||||
fsFsClose(&device->fs);
|
||||
|
||||
memset(device, 0, sizeof(fsdev_fsdevice));
|
||||
|
||||
if(device->id == fsdev_fsdevice_default)
|
||||
fsdev_fsdevice_default = -1;
|
||||
|
||||
if(device->id == fsdev_fsdevice_cwd)
|
||||
fsdev_fsdevice_cwd = fsdev_fsdevice_default;
|
||||
|
||||
device->setup = 0;
|
||||
memset(device->name, 0, sizeof(device->name));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -350,6 +351,17 @@ int fsdevUnmountDevice(const char *name)
|
||||
return _fsdevUnmountDeviceStruct(device);
|
||||
}
|
||||
|
||||
Result fsdevCommitDevice(const char *name)
|
||||
{
|
||||
fsdev_fsdevice *device;
|
||||
|
||||
device = fsdevFindDevice(name);
|
||||
if(device==NULL)
|
||||
return MAKERESULT(MODULE_LIBNX, LIBNX_NOTFOUND);
|
||||
|
||||
return fsFsCommit(&device->fs);
|
||||
}
|
||||
|
||||
/*! Initialize SDMC device */
|
||||
Result fsdevInit(void)
|
||||
{
|
||||
@ -377,6 +389,9 @@ Result fsdevInit(void)
|
||||
fsdevInitialised = true;
|
||||
}
|
||||
|
||||
if(fsdevFindDevice("sdmc"))
|
||||
return 0;
|
||||
|
||||
rc = fsMountSdcard(&fs);
|
||||
if(R_SUCCEEDED(rc))
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user