mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-21 12:32:40 +02:00
fs: Use official method names, document min sysver, correct a few parameters
This commit is contained in:
parent
c77b88d868
commit
54f6fa5420
@ -41,7 +41,7 @@ typedef struct {
|
||||
|
||||
typedef struct {
|
||||
Service s;
|
||||
} FsSaveDataIterator;
|
||||
} FsSaveDataInfoReader;
|
||||
|
||||
typedef struct {
|
||||
Service s;
|
||||
@ -196,7 +196,7 @@ typedef enum
|
||||
FsSaveDataSpaceId_SdCard = 2,
|
||||
FsSaveDataSpaceId_TemporaryStorage = 3,
|
||||
|
||||
FsSaveDataSpaceId_All = -1, ///< Pseudo value for fsOpenSaveDataIterator().
|
||||
FsSaveDataSpaceId_All = -1, ///< Pseudo value for fsOpenSaveDataInfoReader().
|
||||
} FsSaveDataSpaceId;
|
||||
|
||||
typedef enum
|
||||
@ -284,7 +284,7 @@ Result fsOpenBisStorage(FsStorage* out, FsBisStorageId partitionId);
|
||||
Result fsOpenBisFileSystem(FsFileSystem* out, FsBisStorageId partitionId, const char* string);
|
||||
|
||||
Result fsCreateSaveDataFileSystemBySystemSaveDataId(const FsSave* save, const FsSaveCreate* create);
|
||||
Result fsDeleteSaveDataFileSystemBySaveDataSpaceId(FsSaveDataSpaceId saveDataSpaceId, u64 saveID);
|
||||
Result fsDeleteSaveDataFileSystemBySaveDataSpaceId(FsSaveDataSpaceId saveDataSpaceId, u64 saveID); /// [2.0.0+]
|
||||
|
||||
Result fsIsExFatSupported(bool* out);
|
||||
Result fsOpenGameCardFileSystem(FsFileSystem* out, const FsGameCardHandle* handle, FsGameCardPartiton partition);
|
||||
@ -294,11 +294,11 @@ Result fsWriteSaveDataFileSystemExtraData(const void* buf, size_t len, FsSaveDat
|
||||
Result fsExtendSaveDataFileSystem(FsSaveDataSpaceId saveDataSpaceId, u64 saveID, s64 dataSize, s64 journalSize); /// [3.0.0+]
|
||||
|
||||
/// Do not call this directly, see fs_dev.h.
|
||||
Result fsMountSdcard(FsFileSystem* out);
|
||||
Result fsOpenSdCardFileSystem(FsFileSystem* out);
|
||||
|
||||
Result fsMountSaveData(FsFileSystem* out, u8 inval, const FsSave *save);
|
||||
Result fsMountSystemSaveData(FsFileSystem* out, u8 inval, const FsSave *save);
|
||||
Result fsOpenSaveDataIterator(FsSaveDataIterator* out, FsSaveDataSpaceId saveDataSpaceId);
|
||||
Result fsOpenSaveDataFileSystem(FsFileSystem* out, FsSaveDataSpaceId saveDataSpaceId, const FsSave *save);
|
||||
Result fsOpenSaveDataFileSystemBySystemSaveDataId(FsFileSystem* out, FsSaveDataSpaceId saveDataSpaceId, const FsSave *save);
|
||||
Result fsOpenSaveDataInfoReader(FsSaveDataInfoReader* out, FsSaveDataSpaceId saveDataSpaceId);
|
||||
Result fsOpenContentStorageFileSystem(FsFileSystem* out, FsContentStorageId content_storage_id);
|
||||
Result fsOpenCustomStorageFileSystem(FsFileSystem* out, FsCustomStorageId custom_storage_id); /// [7.0.0+]
|
||||
Result fsOpenDataStorageByCurrentProcess(FsStorage* out);
|
||||
@ -324,13 +324,13 @@ Result fsCreate_SystemSaveData(FsSaveDataSpaceId saveDataSpaceId, u64 saveID, u6
|
||||
|
||||
/// FsFileSystem can be mounted with fs_dev for use with stdio, see fs_dev.h.
|
||||
|
||||
/// Wrapper(s) for fsMountSaveData.
|
||||
/// Wrapper(s) for fsOpenSaveDataFileSystem.
|
||||
/// See FsSave for titleID and userID.
|
||||
Result fsMount_SaveData(FsFileSystem* out, u64 titleID, AccountUid *userID);
|
||||
Result fsOpen_SaveData(FsFileSystem* out, u64 titleID, AccountUid *userID);
|
||||
|
||||
/// Wrapper for fsMountSystemSaveData.
|
||||
/// Wrapper for fsOpenSaveDataFileSystemBySystemSaveDataId.
|
||||
/// WARNING: You can brick when writing to SystemSaveData, if the data is corrupted etc.
|
||||
Result fsMount_SystemSaveData(FsFileSystem* out, u64 saveID);
|
||||
Result fsOpen_SystemSaveData(FsFileSystem* out, u64 saveID);
|
||||
|
||||
typedef enum
|
||||
{
|
||||
@ -348,9 +348,9 @@ typedef enum
|
||||
} FsFileSystemQueryType;
|
||||
|
||||
/// Mount requested filesystem type from content file
|
||||
Result fsOpenFileSystem(FsFileSystem* out, FsFileSystemType fsType, const char* contentPath); /// same as calling fsOpenFileSystemWithId with 0 as titleId
|
||||
Result fsOpenFileSystemWithId(FsFileSystem* out, u64 titleId, FsFileSystemType fsType, const char* contentPath); /// works on all firmwares, titleId is ignored on [1.0.0]
|
||||
Result fsOpenFileSystemWithPatch(FsFileSystem* out, u64 titleId, FsFileSystemType fsType); /// [2.0.0+], like OpenFileSystemWithId but without content path.
|
||||
Result fsOpenFileSystem(FsFileSystem* out, FsFileSystemType fsType, const char* contentPath); ///< same as calling fsOpenFileSystemWithId with 0 as titleId
|
||||
Result fsOpenFileSystemWithId(FsFileSystem* out, u64 titleId, FsFileSystemType fsType, const char* contentPath); ///< works on all firmwares, titleId is ignored on [1.0.0]
|
||||
Result fsOpenFileSystemWithPatch(FsFileSystem* out, u64 titleId, FsFileSystemType fsType); ///< [2.0.0+], like OpenFileSystemWithId but without content path.
|
||||
|
||||
// IFileSystem
|
||||
Result fsFsCreateFile(FsFileSystem* fs, const char* path, u64 size, u32 option);
|
||||
@ -366,9 +366,9 @@ Result fsFsOpenDirectory(FsFileSystem* fs, const char* path, u32 mode, FsDir* ou
|
||||
Result fsFsCommit(FsFileSystem* fs);
|
||||
Result fsFsGetFreeSpace(FsFileSystem* fs, const char* path, u64* out);
|
||||
Result fsFsGetTotalSpace(FsFileSystem* fs, const char* path, u64* out);
|
||||
Result fsFsGetFileTimeStampRaw(FsFileSystem* fs, const char* path, FsTimeStampRaw *out); /// [3.0.0+]
|
||||
Result fsFsCleanDirectoryRecursively(FsFileSystem* fs, const char* path); /// [3.0.0+]
|
||||
Result fsFsQueryEntry(FsFileSystem* fs, void *out, size_t out_size, const void *in, size_t in_size, const char* path, FsFileSystemQueryType query_type); /// [4.0.0+]
|
||||
Result fsFsGetFileTimeStampRaw(FsFileSystem* fs, const char* path, FsTimeStampRaw *out); ///< [3.0.0+]
|
||||
Result fsFsCleanDirectoryRecursively(FsFileSystem* fs, const char* path); ///< [3.0.0+]
|
||||
Result fsFsQueryEntry(FsFileSystem* fs, void *out, size_t out_size, const void *in, size_t in_size, const char* path, FsFileSystemQueryType query_type); ///< [4.0.0+]
|
||||
void fsFsClose(FsFileSystem* fs);
|
||||
|
||||
/// Uses \ref fsFsQueryEntry to set the archive bit on the specified absolute directory path.
|
||||
@ -381,7 +381,7 @@ Result fsFileWrite(FsFile* f, u64 off, const void* buf, u64 write_size, u32 opti
|
||||
Result fsFileFlush(FsFile* f);
|
||||
Result fsFileSetSize(FsFile* f, u64 sz);
|
||||
Result fsFileGetSize(FsFile* f, u64* out);
|
||||
Result fsFileOperateRange(FsFile* f, FsOperationId op_id, u64 off, u64 len, FsRangeInfo* out); /// [4.0.0+]
|
||||
Result fsFileOperateRange(FsFile* f, FsOperationId op_id, u64 off, u64 len, FsRangeInfo* out); ///< [4.0.0+]
|
||||
void fsFileClose(FsFile* f);
|
||||
|
||||
// IDirectory
|
||||
@ -395,14 +395,14 @@ Result fsStorageWrite(FsStorage* s, u64 off, const void* buf, u64 write_size);
|
||||
Result fsStorageFlush(FsStorage* s);
|
||||
Result fsStorageSetSize(FsStorage* s, u64 sz);
|
||||
Result fsStorageGetSize(FsStorage* s, u64* out);
|
||||
Result fsStorageOperateRange(FsStorage* s, FsOperationId op_id, u64 off, u64 len, FsRangeInfo* out); /// [4.0.0+]
|
||||
Result fsStorageOperateRange(FsStorage* s, FsOperationId op_id, u64 off, u64 len, FsRangeInfo* out); ///< [4.0.0+]
|
||||
void fsStorageClose(FsStorage* s);
|
||||
|
||||
// ISaveDataInfoReader
|
||||
|
||||
/// Read FsSaveDataInfo data into the buf array.
|
||||
Result fsSaveDataIteratorRead(FsSaveDataIterator *s, FsSaveDataInfo* buf, size_t max_entries, u64* total_entries);
|
||||
void fsSaveDataIteratorClose(FsSaveDataIterator *s);
|
||||
Result fsSaveDataInfoReaderRead(FsSaveDataInfoReader *s, FsSaveDataInfo* buf, size_t max_entries, u64* total_entries);
|
||||
void fsSaveDataInfoReaderClose(FsSaveDataInfoReader *s);
|
||||
|
||||
// IEventNotifier
|
||||
Result fsEventNotifierGetEventHandle(FsEventNotifier* e, Event* out, bool autoclear);
|
||||
|
@ -432,7 +432,7 @@ Result fsdevDeleteDirectoryRecursively(const char *path) {
|
||||
Result fsdevMountSdmc(void)
|
||||
{
|
||||
FsFileSystem fs;
|
||||
Result rc = fsMountSdcard(&fs);
|
||||
Result rc = fsOpenSdCardFileSystem(&fs);
|
||||
if(R_SUCCEEDED(rc))
|
||||
{
|
||||
int ret = fsdevMountDevice("sdmc", fs);
|
||||
|
@ -193,6 +193,9 @@ Result fsCreateSaveDataFileSystemBySystemSaveDataId(const FsSave* save, const Fs
|
||||
}
|
||||
|
||||
Result fsDeleteSaveDataFileSystemBySaveDataSpaceId(FsSaveDataSpaceId saveDataSpaceId, u64 saveID) {
|
||||
if (hosversionBefore(2,0,0))
|
||||
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
|
||||
|
||||
const struct {
|
||||
u8 saveDataSpaceId;
|
||||
u64 saveID;
|
||||
@ -201,18 +204,18 @@ Result fsDeleteSaveDataFileSystemBySaveDataSpaceId(FsSaveDataSpaceId saveDataSpa
|
||||
return _fsObjectDispatchIn(&g_fsSrv, 25, in);
|
||||
}
|
||||
|
||||
Result fsMountSdcard(FsFileSystem* out) {
|
||||
Result fsOpenSdCardFileSystem(FsFileSystem* out) {
|
||||
return _fsObjectDispatch(&g_fsSrv, 18,
|
||||
.out_num_objects = 1,
|
||||
.out_objects = &out->s,
|
||||
);
|
||||
}
|
||||
|
||||
Result fsMountSaveData(FsFileSystem* out, u8 inval, const FsSave *save) {
|
||||
Result fsOpenSaveDataFileSystem(FsFileSystem* out, FsSaveDataSpaceId saveDataSpaceId, const FsSave *save) {
|
||||
const struct {
|
||||
u8 inval;
|
||||
u8 saveDataSpaceId;
|
||||
FsSave save;
|
||||
} in = { inval, *save };
|
||||
} in = { (u8)saveDataSpaceId, *save };
|
||||
|
||||
return _fsObjectDispatchIn(&g_fsSrv, 51, in,
|
||||
.out_num_objects = 1,
|
||||
@ -220,11 +223,11 @@ Result fsMountSaveData(FsFileSystem* out, u8 inval, const FsSave *save) {
|
||||
);
|
||||
}
|
||||
|
||||
Result fsMountSystemSaveData(FsFileSystem* out, u8 inval, const FsSave *save) {
|
||||
Result fsOpenSaveDataFileSystemBySystemSaveDataId(FsFileSystem* out, FsSaveDataSpaceId saveDataSpaceId, const FsSave *save) {
|
||||
const struct {
|
||||
u8 inval;
|
||||
u8 saveDataSpaceId;
|
||||
FsSave save;
|
||||
} in = { inval, *save };
|
||||
} in = { (u8)saveDataSpaceId, *save };
|
||||
|
||||
return _fsObjectDispatchIn(&g_fsSrv, 52, in,
|
||||
.out_num_objects = 1,
|
||||
@ -232,14 +235,14 @@ Result fsMountSystemSaveData(FsFileSystem* out, u8 inval, const FsSave *save) {
|
||||
);
|
||||
}
|
||||
|
||||
static Result _fsOpenSaveDataInfoReader(FsSaveDataIterator* out) {
|
||||
static Result _fsOpenSaveDataInfoReader(FsSaveDataInfoReader* out) {
|
||||
return _fsObjectDispatch(&g_fsSrv, 60,
|
||||
.out_num_objects = 1,
|
||||
.out_objects = &out->s,
|
||||
);
|
||||
}
|
||||
|
||||
static Result _fsOpenSaveDataInfoReaderBySaveDataSpaceId(FsSaveDataIterator* out, FsSaveDataSpaceId saveDataSpaceId) {
|
||||
static Result _fsOpenSaveDataInfoReaderBySaveDataSpaceId(FsSaveDataInfoReader* out, FsSaveDataSpaceId saveDataSpaceId) {
|
||||
u8 in = (u8)saveDataSpaceId;
|
||||
return _fsObjectDispatchIn(&g_fsSrv, 61, in,
|
||||
.out_num_objects = 1,
|
||||
@ -248,7 +251,7 @@ static Result _fsOpenSaveDataInfoReaderBySaveDataSpaceId(FsSaveDataIterator* out
|
||||
|
||||
}
|
||||
|
||||
Result fsOpenSaveDataIterator(FsSaveDataIterator* out, FsSaveDataSpaceId saveDataSpaceId) {
|
||||
Result fsOpenSaveDataInfoReader(FsSaveDataInfoReader* out, FsSaveDataSpaceId saveDataSpaceId) {
|
||||
if (saveDataSpaceId == FsSaveDataSpaceId_All) {
|
||||
return _fsOpenSaveDataInfoReader(out);
|
||||
} else {
|
||||
@ -452,8 +455,8 @@ Result fsCreate_SystemSaveData(FsSaveDataSpaceId saveDataSpaceId, u64 saveID, u6
|
||||
return fsCreate_SystemSaveDataWithOwner(saveDataSpaceId, saveID, 0, 0, size, journalSize, flags);
|
||||
}
|
||||
|
||||
// Wrapper(s) for fsMountSaveData.
|
||||
Result fsMount_SaveData(FsFileSystem* out, u64 titleID, AccountUid *userID) {
|
||||
// Wrapper(s) for fsOpenSaveDataFileSystem.
|
||||
Result fsOpen_SaveData(FsFileSystem* out, u64 titleID, AccountUid *userID) {
|
||||
FsSave save;
|
||||
|
||||
memset(&save, 0, sizeof(save));
|
||||
@ -461,17 +464,17 @@ Result fsMount_SaveData(FsFileSystem* out, u64 titleID, AccountUid *userID) {
|
||||
save.userID = *userID;
|
||||
save.saveDataType = FsSaveDataType_SaveData;
|
||||
|
||||
return fsMountSaveData(out, FsSaveDataSpaceId_NandUser, &save);
|
||||
return fsOpenSaveDataFileSystem(out, FsSaveDataSpaceId_NandUser, &save);
|
||||
}
|
||||
|
||||
Result fsMount_SystemSaveData(FsFileSystem* out, u64 saveID) {
|
||||
Result fsOpen_SystemSaveData(FsFileSystem* out, u64 saveID) {
|
||||
FsSave save;
|
||||
|
||||
memset(&save, 0, sizeof(save));
|
||||
save.saveID = saveID;
|
||||
save.saveDataType = FsSaveDataType_SystemSaveData;
|
||||
|
||||
return fsMountSystemSaveData(out, FsSaveDataSpaceId_NandSystem, &save);
|
||||
return fsOpenSaveDataFileSystemBySystemSaveDataId(out, FsSaveDataSpaceId_NandSystem, &save);
|
||||
}
|
||||
|
||||
Result fsOpenFileSystem(FsFileSystem* out, FsFileSystemType fsType, const char* contentPath) {
|
||||
@ -512,9 +515,8 @@ Result fsOpenFileSystemWithId(FsFileSystem* out, u64 titleId, FsFileSystemType f
|
||||
}
|
||||
|
||||
Result fsOpenFileSystemWithPatch(FsFileSystem* out, u64 titleId, FsFileSystemType fsType) {
|
||||
if (hosversionBefore(2,0,0)) {
|
||||
if (hosversionBefore(2,0,0))
|
||||
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
|
||||
}
|
||||
|
||||
const struct {
|
||||
FsFileSystemType fsType;
|
||||
@ -719,9 +721,8 @@ Result fsFileGetSize(FsFile* f, u64* out) {
|
||||
}
|
||||
|
||||
Result fsFileOperateRange(FsFile* f, FsOperationId op_id, u64 off, u64 len, FsRangeInfo* out) {
|
||||
if (hosversionBefore(4,0,0)) {
|
||||
if (hosversionBefore(4,0,0))
|
||||
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
|
||||
}
|
||||
|
||||
const struct {
|
||||
u32 op_id;
|
||||
@ -793,9 +794,8 @@ Result fsStorageGetSize(FsStorage* s, u64* out) {
|
||||
}
|
||||
|
||||
Result fsStorageOperateRange(FsStorage* s, FsOperationId op_id, u64 off, u64 len, FsRangeInfo* out) {
|
||||
if (hosversionBefore(4,0,0)) {
|
||||
if (hosversionBefore(4,0,0))
|
||||
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
|
||||
}
|
||||
|
||||
const struct {
|
||||
u32 op_id;
|
||||
@ -814,14 +814,15 @@ void fsStorageClose(FsStorage* s) {
|
||||
// ISaveDataInfoReader
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
Result fsSaveDataIteratorRead(FsSaveDataIterator *s, FsSaveDataInfo* buf, size_t max_entries, u64* total_entries) {
|
||||
// Actually called ReadSaveDataInfo
|
||||
Result fsSaveDataInfoReaderRead(FsSaveDataInfoReader *s, FsSaveDataInfo* buf, size_t max_entries, u64* total_entries) {
|
||||
return _fsObjectDispatchOut(&s->s, 0, *total_entries,
|
||||
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out },
|
||||
.buffers = { { buf, sizeof(FsSaveDataInfo)*max_entries } },
|
||||
);
|
||||
}
|
||||
|
||||
void fsSaveDataIteratorClose(FsSaveDataIterator* s) {
|
||||
void fsSaveDataInfoReaderClose(FsSaveDataInfoReader* s) {
|
||||
_fsObjectClose(&s->s);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user