diff --git a/src/LibHac/Fs/FsEnums.cs b/src/LibHac/Fs/FsEnums.cs index 210d231d..cb187dc8 100644 --- a/src/LibHac/Fs/FsEnums.cs +++ b/src/LibHac/Fs/FsEnums.cs @@ -59,4 +59,24 @@ User = 0, SdCard = 1 } + + public enum FileSystemType + { + Code = 0, + Data = 1, + Logo = 2, + ContentControl = 3, + ContentManual = 4, + ContentMeta = 5, + ContentData = 6, + ApplicationPackage = 7, + RegisteredUpdate = 8 + } + + public enum SaveMetaType : byte + { + None = 0, + Thumbnail = 1, + ExtensionInfo = 2 + } } diff --git a/src/LibHac/Fs/Save/Header.cs b/src/LibHac/Fs/Save/Header.cs index d6d06a67..a0bc4ef8 100644 --- a/src/LibHac/Fs/Save/Header.cs +++ b/src/LibHac/Fs/Save/Header.cs @@ -280,13 +280,13 @@ namespace LibHac.Fs.Save } } - public enum SaveDataType + public enum SaveDataType : byte { - SystemSaveData, - SaveData, - BcatDeliveryCacheStorage, - DeviceSaveData, - TemporaryStorage, - CacheStorage + SystemSaveData = 0, + SaveData = 1, + BcatDeliveryCacheStorage = 2, + DeviceSaveData = 3, + TemporaryStorage = 4, + CacheStorage = 5 } } diff --git a/src/LibHac/Fs/SaveDataAttribute2.cs b/src/LibHac/Fs/SaveDataAttribute2.cs new file mode 100644 index 00000000..0dd628a7 --- /dev/null +++ b/src/LibHac/Fs/SaveDataAttribute2.cs @@ -0,0 +1,16 @@ +using System.Runtime.InteropServices; +using LibHac.Fs.Save; + +namespace LibHac.Fs +{ + [StructLayout(LayoutKind.Explicit, Size = 0x40)] + public struct SaveDataAttribute2 + { + [FieldOffset(0x00)] public ulong TitleId; + [FieldOffset(0x08)] public UserId UserId; + [FieldOffset(0x18)] public ulong SaveDataId; + [FieldOffset(0x20)] public SaveDataType Type; + [FieldOffset(0x21)] public byte Rank; + [FieldOffset(0x22)] public short Index; + } +} diff --git a/src/LibHac/Fs/SaveDataCreateInfo.cs b/src/LibHac/Fs/SaveDataCreateInfo.cs new file mode 100644 index 00000000..9dee82af --- /dev/null +++ b/src/LibHac/Fs/SaveDataCreateInfo.cs @@ -0,0 +1,10 @@ +using System.Runtime.InteropServices; + +namespace LibHac.Fs +{ + [StructLayout(LayoutKind.Explicit, Size = 0x40)] + public struct SaveDataCreateInfo + { + // Todo + } +} diff --git a/src/LibHac/Fs/SaveMetaCreateInfo.cs b/src/LibHac/Fs/SaveMetaCreateInfo.cs new file mode 100644 index 00000000..c22202db --- /dev/null +++ b/src/LibHac/Fs/SaveMetaCreateInfo.cs @@ -0,0 +1,11 @@ +using System.Runtime.InteropServices; + +namespace LibHac.Fs +{ + [StructLayout(LayoutKind.Explicit, Size = 0x10)] + public struct SaveMetaCreateInfo + { + [FieldOffset(0)] public int Size; + [FieldOffset(4)] public SaveMetaType Type; + } +} diff --git a/src/LibHac/FsService/IFileSystemProxy.cs b/src/LibHac/FsService/IFileSystemProxy.cs index 59d665f3..61b7a1b7 100644 --- a/src/LibHac/FsService/IFileSystemProxy.cs +++ b/src/LibHac/FsService/IFileSystemProxy.cs @@ -1,13 +1,28 @@ using System; +using LibHac.Common; using LibHac.Fs; +using LibHac.Ncm; namespace LibHac.FsService { public interface IFileSystemProxy { Result SetCurrentProcess(long processId); - Result OpenBisFileSystem(out IFileSystem fileSystem, string rootPath, BisPartitionId partitionId); + Result OpenDataFileSystemByCurrentProcess(out IFileSystem fileSystem); + Result OpenFileSystemWithPatch(out IFileSystem fileSystem, TitleId titleId, FileSystemType type); + Result OpenFileSystemWithId(out IFileSystem fileSystem, U8Span path, TitleId titleId, FileSystemType type); + Result OpenDataFileSystemByProgramId(out IFileSystem fileSystem, TitleId titleId); + Result OpenBisFileSystem(out IFileSystem fileSystem, U8Span rootPath, BisPartitionId partitionId); + Result OpenBisStorage(out IStorage storage, BisPartitionId partitionId); + Result InvalidateBisCache(); + Result OpenHostFileSystem(out IFileSystem fileSystem, U8Span subPath); Result OpenSdCardFileSystem(out IFileSystem fileSystem); + Result FormatSdCardFileSystem(); + Result DeleteSaveDataFileSystem(long saveDataId); + Result CreateSaveDataFileSystem(ref SaveDataAttribute2 attribute, ref SaveDataCreateInfo createInfo, ref SaveMetaCreateInfo metaCreateInfo); + Result CreateSaveDataFileSystemBySystemSaveDataId(ref SaveDataAttribute2 attribute, ref SaveDataCreateInfo createInfo); + Result RegisterSaveDataFileSystemAtomicDeletion(ReadOnlySpan saveDataIds); + Result OpenGameCardStorage(out IStorage storage, GameCardHandle handle, GameCardPartitionRaw partitionId); Result OpenSaveDataFileSystem(out IFileSystem fileSystem, SaveDataSpaceId spaceId, SaveDataAttribute attribute); Result OpenSaveDataFileSystemBySystemSaveDataId(out IFileSystem fileSystem, SaveDataSpaceId spaceId, SaveDataAttribute attribute); @@ -15,7 +30,7 @@ namespace LibHac.FsService Result OpenCustomStorageFileSystem(out IFileSystem fileSystem, CustomStorageId storageId); Result SetSdCardEncryptionSeed(ReadOnlySpan seed); Result SetSaveDataSize(long saveDataSize, long saveDataJournalSize); - Result SetSaveDataRootPath(string path); + Result SetSaveDataRootPath(U8Span path); Result DisableAutoSaveDataCreation(); } } \ No newline at end of file diff --git a/src/LibHac/Ncm/TitleId.cs b/src/LibHac/Ncm/TitleId.cs new file mode 100644 index 00000000..9502bf10 --- /dev/null +++ b/src/LibHac/Ncm/TitleId.cs @@ -0,0 +1,9 @@ +namespace LibHac.Ncm +{ + public struct TitleId + { + public ulong Value; + + public static explicit operator ulong(TitleId titleId) => titleId.Value; + } +}