mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-21 20:42:44 +02:00
fs/fs_dev: Added fsOpen_BcatSaveData/fsOpen_SystemBcatSaveData and fsdevMountBcatSaveData/fsdevMountSystemBcatSaveData.
This commit is contained in:
parent
014b02db97
commit
918fe2b4d6
@ -30,15 +30,22 @@ NX_CONSTEXPR FsDirectoryEntry* fsdevDirGetEntries(fsdev_dir_t *dir)
|
||||
/// Initializes and mounts the sdmc device if accessible.
|
||||
Result fsdevMountSdmc(void);
|
||||
|
||||
/// Mounts the specified save data.
|
||||
/// Mounts the specified SaveData.
|
||||
Result fsdevMountSaveData(const char *name, u64 application_id, AccountUid uid);
|
||||
|
||||
/// Mounts the specified BcatSaveData.
|
||||
Result fsdevMountBcatSaveData(const char *name, u64 application_id);
|
||||
|
||||
/// Mounts the specified DeviceSaveData.
|
||||
Result fsdevMountDeviceSaveData(const char *name, u64 application_id);
|
||||
|
||||
/// Mounts the specified system save data.
|
||||
/// Mounts the specified SystemSaveData.
|
||||
Result fsdevMountSystemSaveData(const char *name, FsSaveDataSpaceId save_data_space_id, u64 system_save_data_id, AccountUid uid);
|
||||
|
||||
/// Mounts the specified SystemBcatSaveData.
|
||||
/// Only available on [4.0.0+].
|
||||
Result fsdevMountSystemBcatSaveData(const char *name, u64 system_save_data_id);
|
||||
|
||||
/// 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.
|
||||
/// Input device name string shouldn't exceed 31 characters, and shouldn't have a trailing colon.
|
||||
|
@ -371,14 +371,21 @@ Result fsCreate_SystemSaveData(FsSaveDataSpaceId save_data_space_id, u64 system_
|
||||
/// See \ref FsSaveDataAttribute for application_id and uid.
|
||||
Result fsOpen_SaveData(FsFileSystem* out, u64 application_id, AccountUid uid);
|
||||
|
||||
/// Wrapper for fsOpenSaveDataFileSystem, for opening BcatSaveData.
|
||||
Result fsOpen_BcatSaveData(FsFileSystem* out, u64 application_id);
|
||||
|
||||
/// Wrapper for fsOpenSaveDataFileSystem, for opening DeviceSaveData.
|
||||
/// See \ref FsSaveDataAttribute for application_id.
|
||||
Result fsOpen_DeviceSaveData(FsFileSystem* out, u64 application_id);
|
||||
|
||||
/// Wrapper for fsOpenSaveDataFileSystemBySystemSaveDataId.
|
||||
/// Wrapper for fsOpenSaveDataFileSystemBySystemSaveDataId, for opening SystemSaveData.
|
||||
/// WARNING: You can brick when writing to SystemSaveData, if the data is corrupted etc.
|
||||
Result fsOpen_SystemSaveData(FsFileSystem* out, FsSaveDataSpaceId save_data_space_id, u64 system_save_data_id, AccountUid uid);
|
||||
|
||||
/// Wrapper for fsOpenSaveDataFileSystemBySystemSaveDataId, for opening SystemBcatSaveData.
|
||||
/// Only available on [4.0.0+].
|
||||
Result fsOpen_SystemBcatSaveData(FsFileSystem* out, u64 system_save_data_id);
|
||||
|
||||
// IFileSystem
|
||||
Result fsFsCreateFile(FsFileSystem* fs, const char* path, s64 size, u32 option);
|
||||
Result fsFsDeleteFile(FsFileSystem* fs, const char* path);
|
||||
|
@ -465,6 +465,19 @@ Result fsdevMountSaveData(const char *name, u64 application_id, AccountUid uid)
|
||||
return rc;
|
||||
}
|
||||
|
||||
Result fsdevMountBcatSaveData(const char *name, u64 application_id)
|
||||
{
|
||||
FsFileSystem fs;
|
||||
Result rc = fsOpen_BcatSaveData(&fs, application_id);
|
||||
if(R_SUCCEEDED(rc))
|
||||
{
|
||||
int ret = fsdevMountDevice(name, fs);
|
||||
if(ret==-1)
|
||||
rc = MAKERESULT(Module_Libnx, LibnxError_OutOfMemory);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
Result fsdevMountDeviceSaveData(const char *name, u64 application_id)
|
||||
{
|
||||
FsFileSystem fs;
|
||||
@ -491,6 +504,19 @@ Result fsdevMountSystemSaveData(const char *name, FsSaveDataSpaceId save_data_sp
|
||||
return rc;
|
||||
}
|
||||
|
||||
Result fsdevMountSystemBcatSaveData(const char *name, u64 system_save_data_id)
|
||||
{
|
||||
FsFileSystem fs;
|
||||
Result rc = fsOpen_SystemBcatSaveData(&fs, system_save_data_id);
|
||||
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)
|
||||
|
@ -498,6 +498,16 @@ Result fsOpen_SaveData(FsFileSystem* out, u64 application_id, AccountUid uid) {
|
||||
return _fsOpen_SaveDataFs(out, &attr);
|
||||
}
|
||||
|
||||
Result fsOpen_BcatSaveData(FsFileSystem* out, u64 application_id) {
|
||||
FsSaveDataAttribute attr;
|
||||
|
||||
memset(&attr, 0, sizeof(attr));
|
||||
attr.application_id = application_id;
|
||||
attr.save_data_type = FsSaveDataType_Bcat;
|
||||
|
||||
return _fsOpen_SaveDataFs(out, &attr);
|
||||
}
|
||||
|
||||
Result fsOpen_DeviceSaveData(FsFileSystem* out, u64 application_id) {
|
||||
FsSaveDataAttribute attr;
|
||||
|
||||
@ -519,6 +529,19 @@ Result fsOpen_SystemSaveData(FsFileSystem* out, FsSaveDataSpaceId save_data_spac
|
||||
return fsOpenSaveDataFileSystemBySystemSaveDataId(out, save_data_space_id, &attr);
|
||||
}
|
||||
|
||||
Result fsOpen_SystemBcatSaveData(FsFileSystem* out, u64 system_save_data_id) {
|
||||
if (hosversionBefore(4,0,0))
|
||||
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
|
||||
|
||||
FsSaveDataAttribute attr;
|
||||
|
||||
memset(&attr, 0, sizeof(attr));
|
||||
attr.system_save_data_id = system_save_data_id;
|
||||
attr.save_data_type = FsSaveDataType_SystemBcat;
|
||||
|
||||
return fsOpenSaveDataFileSystemBySystemSaveDataId(out, FsSaveDataSpaceId_System, &attr);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// IFileSystem
|
||||
//-----------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user