diff --git a/nx/include/switch/services/fs.h b/nx/include/switch/services/fs.h index 6a0b87b6..210ac000 100644 --- a/nx/include/switch/services/fs.h +++ b/nx/include/switch/services/fs.h @@ -313,6 +313,12 @@ typedef enum { FsPriority_Background = 3, } FsPriority; +/// For use with fsOpenHostFileSystemWithOption +typedef enum { + FsMountHostOptionFlag_None = 0, ///< Host filesystem will be case insensitive. + FsMountHostOptionFlag_PseudoCaseSensitive = BIT(0), ///< Host filesystem will be pseudo case sensitive. +} FsMountHostOption; + /// Initialize fsp-srv. Used automatically during app startup. Result fsInitialize(void); @@ -337,6 +343,9 @@ Result fsOpenBisStorage(FsStorage* out, FsBisPartitionId partitionId); /// Do not call this directly, see fs_dev.h. Result fsOpenSdCardFileSystem(FsFileSystem* out); +Result fsOpenHostFileSystem(FsFileSystem* out, const char *path); +Result fsOpenHostFileSystemWithOption(FsFileSystem* out, const char *path, u32 flags); ///< [9.0.0+] + Result fsDeleteSaveDataFileSystem(u64 application_id); Result fsCreateSaveDataFileSystem(const FsSaveDataAttribute* attr, const FsSaveDataCreationInfo* creation_info, const FsSaveDataMetaInfo* meta); Result fsCreateSaveDataFileSystemBySystemSaveDataId(const FsSaveDataAttribute* attr, const FsSaveDataCreationInfo* creation_info); diff --git a/nx/source/services/fs.c b/nx/source/services/fs.c index 7667e812..658da25d 100644 --- a/nx/source/services/fs.c +++ b/nx/source/services/fs.c @@ -224,6 +224,33 @@ Result fsOpenSdCardFileSystem(FsFileSystem* out) { return _fsCmdGetSession(&g_fsSrv, &out->s, 18); } +Result fsOpenHostFileSystem(FsFileSystem* out, const char *path) { + char tmpstr[FS_MAX_PATH] = {0}; + strncpy(tmpstr, path, sizeof(tmpstr)-1); + + return _fsObjectDispatch(&g_fsSrv, 17, + .buffer_attrs = { SfBufferAttr_HipcPointer | SfBufferAttr_In }, + .buffers = { { tmpstr, sizeof(tmpstr) } }, + .out_num_objects = 1, + .out_objects = &out->s, + ); +} + +Result fsOpenHostFileSystemWithOption(FsFileSystem* out, const char *path, u32 flags) { + if (hosversionBefore(9,0,0)) + return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); + + char tmpstr[FS_MAX_PATH] = {0}; + strncpy(tmpstr, path, sizeof(tmpstr)-1); + + return _fsObjectDispatchIn(&g_fsSrv, 36, flags, + .buffer_attrs = { SfBufferAttr_HipcPointer | SfBufferAttr_In }, + .buffers = { { tmpstr, sizeof(tmpstr) } }, + .out_num_objects = 1, + .out_objects = &out->s, + ); +} + Result fsDeleteSaveDataFileSystem(u64 application_id) { return _fsObjectDispatchIn(&g_fsSrv, 21, application_id); }