mirror of
https://github.com/switchbrew/libnx.git
synced 2025-07-05 02:52:13 +02:00
Add fsOpenFileSystem and fsOpenFileSystemWithId
This commit is contained in:
parent
117614becd
commit
aa0a8e8c6c
@ -167,6 +167,20 @@ Result fsMount_SaveData(FsFileSystem* out, u64 titleID, u128 userID);
|
||||
/// WARNING: You can brick when writing to SystemSaveData, if the data is corrupted etc.
|
||||
Result fsMount_SystemSaveData(FsFileSystem* out, u64 saveID);
|
||||
|
||||
typedef enum
|
||||
{
|
||||
FsFileSystemType_Logo = 2,
|
||||
FsFileSystemType_ContentControl = 3,
|
||||
FsFileSystemType_ContentManual = 4,
|
||||
FsFileSystemType_ContentMeta = 5,
|
||||
FsFileSystemType_ContentData = 6,
|
||||
FsFileSystemType_ApplicationPackage = 7
|
||||
} FsFileSystemType;
|
||||
|
||||
/// Mount requested filesystem type from content file
|
||||
Result fsOpenFileSystem(FsFileSystem* out, u64 titleId, FsFileSystemType fsType); /// only on 1.0.0, only works with registered content
|
||||
Result fsOpenFileSystemWithId(FsFileSystem* out, u64 titleId, FsFileSystemType fsType, const char* contentPath); /// 2.0.0+, contentPath must be resolved manually
|
||||
|
||||
// IFileSystem
|
||||
Result fsFsCreateFile(FsFileSystem* fs, const char* path, size_t size, int flags);
|
||||
Result fsFsDeleteFile(FsFileSystem* fs, const char* path);
|
||||
|
@ -391,6 +391,85 @@ Result fsMount_SystemSaveData(FsFileSystem* out, u64 saveID) {
|
||||
return fsMountSystemSaveData(out, FsSaveDataSpaceId_NandSystem, &save);
|
||||
}
|
||||
|
||||
Result fsOpenFileSystem(FsFileSystem* out, u64 titleId, FsFileSystemType fsType) {
|
||||
IpcCommand c;
|
||||
ipcInitialize(&c);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 cmd_id;
|
||||
u32 fsType;
|
||||
u64 titleId;
|
||||
} *raw;
|
||||
|
||||
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 0;
|
||||
raw->fsType = fsType;
|
||||
raw->titleId = titleId;
|
||||
|
||||
Result rc = serviceIpcDispatch(&g_fsSrv);
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
ipcParse(&r);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
} *resp = r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
serviceCreate(&out->s, r.Handles[0]);
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
Result fsOpenFileSystemWithId(FsFileSystem* out, u64 titleId, FsFileSystemType fsType, const char* contentPath) {
|
||||
IpcCommand c;
|
||||
ipcInitialize(&c);
|
||||
ipcAddSendStatic(&c, contentPath, strlen(contentPath)+1, 0);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 cmd_id;
|
||||
u32 fsType;
|
||||
u64 titleId;
|
||||
} *raw;
|
||||
|
||||
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 8;
|
||||
raw->fsType = fsType;
|
||||
raw->titleId = titleId;
|
||||
|
||||
Result rc = serviceIpcDispatch(&g_fsSrv);
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
ipcParse(&r);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
} *resp = r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
serviceCreate(&out->s, r.Handles[0]);
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
// IFileSystem impl
|
||||
Result fsFsCreateFile(FsFileSystem* fs, const char* path, size_t size, int flags) {
|
||||
IpcCommand c;
|
||||
|
Loading…
Reference in New Issue
Block a user