fsdev: Added fsdevMountSaveData/SystemSaveData wrappers

This commit is contained in:
fincs 2019-10-21 12:38:18 +02:00
parent 54f6fa5420
commit 13fbde91b0
No known key found for this signature in database
GPG Key ID: 62C7609ADA219C60
2 changed files with 32 additions and 0 deletions

View File

@ -30,6 +30,12 @@ NX_CONSTEXPR FsDirectoryEntry* fsdevDirGetEntries(fsdev_dir_t *dir)
/// Initializes and mounts the sdmc device if accessible.
Result fsdevMountSdmc(void);
/// Mounts the specified save data.
Result fsdevMountSaveData(const char *name, u64 titleID, AccountUid *userID);
/// Mounts the specified system save data.
Result fsdevMountSystemSaveData(const char *name, u64 saveID);
/// 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);

View File

@ -443,6 +443,32 @@ Result fsdevMountSdmc(void)
return rc;
}
Result fsdevMountSaveData(const char *name, u64 titleID, AccountUid *userID)
{
FsFileSystem fs;
Result rc = fsOpen_SaveData(&fs, titleID, userID);
if(R_SUCCEEDED(rc))
{
int ret = fsdevMountDevice(name, fs);
if(ret==-1)
rc = MAKERESULT(Module_Libnx, LibnxError_OutOfMemory);
}
return rc;
}
Result fsdevMountSystemSaveData(const char *name, u64 saveID)
{
FsFileSystem fs;
Result rc = fsOpen_SystemSaveData(&fs, saveID);
if(R_SUCCEEDED(rc))
{
int ret = fsdevMountDevice(name, fs);
if(ret==-1)
rc = MAKERESULT(Module_Libnx, LibnxError_OutOfMemory);
}
return rc;
}
void __libnx_init_cwd(void)
{
if(envIsNso() || __system_argc==0 || __system_argv[0] == NULL)