From 5345d2747e0412c1f11b142650b3ac863fdab951 Mon Sep 17 00:00:00 2001 From: Alex Barney Date: Mon, 24 Feb 2020 14:45:51 -0700 Subject: [PATCH] Generate Results from a .csv file --- build/Build.cs | 9 +- build/CodeGen/IndentingStringBuilder.cs | 74 ++++++ build/CodeGen/ResultCodegen.cs | 300 ++++++++++++++++++++++++ build/CodeGen/result_modules.csv | 4 + build/CodeGen/result_paths.csv | 4 + build/CodeGen/results.csv | 199 ++++++++++++++++ build/_build.csproj | 2 + src/LibHac/Fs/ResultFs.cs | 37 +-- 8 files changed, 592 insertions(+), 37 deletions(-) create mode 100644 build/CodeGen/IndentingStringBuilder.cs create mode 100644 build/CodeGen/ResultCodegen.cs create mode 100644 build/CodeGen/result_modules.csv create mode 100644 build/CodeGen/result_paths.csv create mode 100644 build/CodeGen/results.csv diff --git a/build/Build.cs b/build/Build.cs index 0b1d0012..83379fbc 100644 --- a/build/Build.cs +++ b/build/Build.cs @@ -8,6 +8,7 @@ using System.Security.Cryptography; using System.Text; using System.Text.RegularExpressions; using ICSharpCode.SharpZipLib.Zip; +using LibHacBuild.CodeGen; using Nuke.Common; using Nuke.Common.CI.AppVeyor; using Nuke.Common.Git; @@ -181,8 +182,14 @@ namespace LibHacBuild DotNetRestore(s => settings); }); + Target Codegen => _ => _ + .Executes(() => + { + ResultCodeGen.Run(); + }); + Target Compile => _ => _ - .DependsOn(Restore, SetVersion) + .DependsOn(Restore, SetVersion, Codegen) .Executes(() => { DotNetBuildSettings buildSettings = new DotNetBuildSettings() diff --git a/build/CodeGen/IndentingStringBuilder.cs b/build/CodeGen/IndentingStringBuilder.cs new file mode 100644 index 00000000..31b601d4 --- /dev/null +++ b/build/CodeGen/IndentingStringBuilder.cs @@ -0,0 +1,74 @@ +using System; +using System.Text; + +namespace LibHacBuild.CodeGen +{ + public class IndentingStringBuilder + { + public int LevelSize { get; set; } = 4; + public int Level { get; private set; } + + private StringBuilder _sb = new StringBuilder(); + private string _indentation = string.Empty; + private bool _hasIndentedCurrentLine; + + public IndentingStringBuilder() { } + public IndentingStringBuilder(int levelSize) => LevelSize = levelSize; + + public void SetLevel(int level) + { + Level = Math.Max(level, 0); + _indentation = new string(' ', Level * LevelSize); + } + + public void IncreaseLevel() => SetLevel(Level + 1); + public void DecreaseLevel() => SetLevel(Level - 1); + + public IndentingStringBuilder AppendLine() + { + _sb.AppendLine(); + _hasIndentedCurrentLine = false; + return this; + } + + public IndentingStringBuilder AppendLine(string value) + { + IndentIfNeeded(); + _sb.AppendLine(value); + _hasIndentedCurrentLine = false; + return this; + } + + public IndentingStringBuilder Append(string value) + { + IndentIfNeeded(); + _sb.Append(value); + return this; + } + + public IndentingStringBuilder AppendLineAndIncrease(string value) + { + AppendLine(value); + IncreaseLevel(); + return this; + } + + public IndentingStringBuilder DecreaseAndAppendLine(string value) + { + DecreaseLevel(); + AppendLine(value); + return this; + } + + private void IndentIfNeeded() + { + if (!_hasIndentedCurrentLine) + { + _sb.Append(_indentation); + _hasIndentedCurrentLine = true; + } + } + + public override string ToString() => _sb.ToString(); + } +} diff --git a/build/CodeGen/ResultCodegen.cs b/build/CodeGen/ResultCodegen.cs new file mode 100644 index 00000000..df4f7af9 --- /dev/null +++ b/build/CodeGen/ResultCodegen.cs @@ -0,0 +1,300 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Text; +using CsvHelper; +using Nuke.Common; + +namespace LibHacBuild.CodeGen +{ + public static class ResultCodeGen + { + // RyuJIT will always be inlined a function if its CIL size is <= 0x10 bytes + private const int InlineThreshold = 0x10; + + public static void Run() + { + ModuleInfo[] modules = ReadResults(); + + SetEmptyResultNames(modules); + CheckIfAggressiveInliningNeeded(modules); + SetOutputPaths(modules); + + foreach (ModuleInfo module in modules) + { + string moduleResultFile = PrintModule(module); + + WriteOutput(module, moduleResultFile); + } + } + + private static ModuleInfo[] ReadResults() + { + ModuleIndex[] moduleNames = ReadCsv("result_modules.csv"); + ModulePath[] modulePaths = ReadCsv("result_paths.csv"); + ResultInfo[] results = ReadCsv("results.csv"); + + var modules = new Dictionary(); + + foreach (ModuleIndex name in moduleNames) + { + var module = new ModuleInfo(); + module.Name = name.Name; + module.Index = name.Index; + + modules.Add(name.Name, module); + } + + foreach (ModulePath path in modulePaths) + { + ModuleInfo module = modules[path.Name]; + module.Namespace = path.Namespace; + module.Path = path.Path; + } + + foreach (ModuleInfo module in modules.Values) + { + module.Results = results.Where(x => x.Module == module.Index).OrderBy(x => x.DescriptionStart) + .ToArray(); + } + + return modules.Values.ToArray(); + } + + private static void SetEmptyResultNames(ModuleInfo[] modules) + { + foreach (ModuleInfo module in modules) + { + foreach (ResultInfo result in module.Results.Where(x => string.IsNullOrWhiteSpace(x.Name))) + { + if (result.DescriptionEnd.HasValue) + { + result.Name += $"Range{result.DescriptionStart}To{result.DescriptionEnd}"; + } + else + { + result.Name = $"Result{result.DescriptionStart}"; + } + } + } + } + + private static void CheckIfAggressiveInliningNeeded(ModuleInfo[] modules) + { + foreach (ModuleInfo module in modules) + { + module.NeedsAggressiveInlining = module.Results.Any(x => EstimateCilSize(x) > InlineThreshold); + } + } + + private static void SetOutputPaths(ModuleInfo[] modules) + { + string rootPath = FindProjectDirectory(); + + foreach (ModuleInfo module in modules.Where(x => !string.IsNullOrWhiteSpace(x.Path))) + { + module.FullPath = Path.Combine(rootPath, module.Path); + } + } + + private static string PrintModule(ModuleInfo module) + { + var sb = new IndentingStringBuilder(); + + if (module.NeedsAggressiveInlining) + { + sb.AppendLine("using System.Runtime.CompilerServices;"); + sb.AppendLine(); + } + + sb.AppendLine($"namespace {module.Namespace}"); + sb.AppendLineAndIncrease("{"); + + sb.AppendLine($"public static class Result{module.Name}"); + sb.AppendLineAndIncrease("{"); + + sb.AppendLine($"public const int Module{module.Name} = {module.Index};"); + sb.AppendLine(); + + foreach (ResultInfo result in module.Results) + { + PrintResult(sb, module.Name, result); + } + + sb.DecreaseAndAppendLine("}"); + sb.DecreaseAndAppendLine("}"); + + return sb.ToString(); + } + + private static void PrintResult(IndentingStringBuilder sb, string moduleName, ResultInfo result) + { + string descriptionArgs; + + if (result.DescriptionEnd.HasValue) + { + descriptionArgs = $"{result.DescriptionStart}, {result.DescriptionEnd}"; + } + else + { + descriptionArgs = $"{result.DescriptionStart}"; + } + + // sb.AppendLine($"/// Error code: {result.ErrorCode}; Inner value: 0x{result.InnerValue:x}"); + + string resultCtor = $"new Result.Base(Module{moduleName}, {descriptionArgs});"; + sb.Append($"public static Result.Base {result.Name} "); + + if (EstimateCilSize(result) > InlineThreshold) + { + sb.AppendLine($"{{ [MethodImpl(MethodImplOptions.AggressiveInlining)] get => {resultCtor} }}"); + } + else + { + sb.AppendLine($"=> {resultCtor}"); + } + } + + // Write the file only if it has changed + // Preserve the UTF-8 BOM usage if the file already exists + private static void WriteOutput(ModuleInfo module, string text) + { + if (string.IsNullOrWhiteSpace(module.FullPath)) + return; + + // Default is true because Visual Studio saves .cs files with the BOM by default + bool hasBom = true; + byte[] bom = Encoding.UTF8.GetPreamble(); + byte[] oldFile = null; + + if (File.Exists(module.FullPath)) + { + oldFile = File.ReadAllBytes(module.FullPath); + + if (oldFile.Length >= 3) + hasBom = oldFile.AsSpan(0, 3).SequenceEqual(bom); + } + + byte[] newFile = (hasBom ? bom : new byte[0]).Concat(Encoding.UTF8.GetBytes(text)).ToArray(); + + if (oldFile?.SequenceEqual(newFile) == true) + { + Logger.Normal($"{module.Path} is already up-to-date"); + return; + } + + Logger.Normal($"Generated file {module.Path}"); + File.WriteAllBytes(module.FullPath, newFile); + } + + private static T[] ReadCsv(string name) + { + using (var csv = new CsvReader(new StreamReader(GetResource(name)), CultureInfo.InvariantCulture)) + { + csv.Configuration.AllowComments = true; + + return csv.GetRecords().ToArray(); + } + } + + private static Stream GetResource(string name) + { + var assembly = Assembly.GetExecutingAssembly(); + string path = $"LibHacBuild.CodeGen.{name}"; + + Stream stream = assembly.GetManifestResourceStream(path); + if (stream == null) throw new FileNotFoundException($"Resource {path} was not found."); + + return stream; + } + + private static string FindProjectDirectory() + { + string currentDir = Environment.CurrentDirectory; + + while (currentDir != null) + { + if (File.Exists(Path.Combine(currentDir, "LibHac.sln"))) + { + break; + } + + currentDir = Path.GetDirectoryName(currentDir); + } + + if (currentDir == null) + throw new DirectoryNotFoundException("Unable to find project directory."); + + return Path.Combine(currentDir, "src"); + } + + private static int EstimateCilSize(ResultInfo result) + { + int size = 0; + + size += GetLoadSize(result.Module); + size += GetLoadSize(result.DescriptionStart); + + if (result.DescriptionEnd.HasValue) + size += GetLoadSize(result.DescriptionEnd.Value); + + size += 5; // newobj + size += 1; // ret + + return size; + + static int GetLoadSize(int value) + { + if (value >= -1 && value <= 8) + return 1; // ldc.i4.X + + if (value >= sbyte.MinValue && value <= sbyte.MaxValue) + return 2; // ldc.i4.s XX + + return 5; // ldc.i4 XXXXXXXX + } + } + } + + public class ModuleIndex + { + public string Name { get; set; } + public int Index { get; set; } + } + + public class ModulePath + { + public string Name { get; set; } + public string Namespace { get; set; } + public string Path { get; set; } + } + + [DebuggerDisplay("{" + nameof(Name) + ",nq}")] + public class ModuleInfo + { + public string Name { get; set; } + public int Index { get; set; } + public string Namespace { get; set; } + public string Path { get; set; } + + public string FullPath { get; set; } + public bool NeedsAggressiveInlining { get; set; } + public ResultInfo[] Results { get; set; } + } + + [DebuggerDisplay("{" + nameof(Name) + ",nq}")] + public class ResultInfo + { + public int Module { get; set; } + public int DescriptionStart { get; set; } + public int? DescriptionEnd { get; set; } + public string Name { get; set; } + + public string ErrorCode => $"{2000 + Module:d4}-{DescriptionStart:d4}"; + public int InnerValue => Module & 0x1ff | ((DescriptionStart & 0x7ffff) << 9); + } +} diff --git a/build/CodeGen/result_modules.csv b/build/CodeGen/result_modules.csv new file mode 100644 index 00000000..ffd4d6e4 --- /dev/null +++ b/build/CodeGen/result_modules.csv @@ -0,0 +1,4 @@ +Name,Index +Fs,2 +Kvdb,20 +Sdmmc,24 \ No newline at end of file diff --git a/build/CodeGen/result_paths.csv b/build/CodeGen/result_paths.csv new file mode 100644 index 00000000..cca028c2 --- /dev/null +++ b/build/CodeGen/result_paths.csv @@ -0,0 +1,4 @@ +Name,Namespace,Path +Fs,LibHac.Fs,LibHac/Fs/ResultFs.cs +Kvdb,LibHac.Kvdb,LibHac/Kvdb/ResultKvdb.cs +Sdmmc,LibHac.FsService,LibHac/FsService/ResultSdmmc.cs \ No newline at end of file diff --git a/build/CodeGen/results.csv b/build/CodeGen/results.csv new file mode 100644 index 00000000..86b52cd1 --- /dev/null +++ b/build/CodeGen/results.csv @@ -0,0 +1,199 @@ +Module,DescriptionStart,DescriptionEnd,Name +2,1,,PathNotFound +2,2,,PathAlreadyExists +2,7,,TargetLocked +2,8,,DirectoryNotEmpty + +2,30,45,InsufficientFreeSpace +2,34,38,InsufficientFreeSpaceBis +2,35,,InsufficientFreeSpaceBisCalibration +2,36,,InsufficientFreeSpaceBisSafe +2,37,,InsufficientFreeSpaceBisUser +2,38,,InsufficientFreeSpaceBisSystem +2,39,,InsufficientFreeSpaceSdCard +2,60,,MountNameAlreadyExists + +2,1001,,PartitionNotFound +2,1002,,TargetNotFound +2,1004,,ExternalKeyNotFound + +2,2000,2499,SdCardAccessFailed +2,2001,,SdCardNotFound +2,2004,,SdCardAsleep + +2,2500,2999,GameCardAccessFailed +2,2503,,InvalidBufferForGameCard +2,2520,,GameCardNotInserted +2,2951,,GameCardNotInsertedOnGetHandle +2,2952,,InvalidGameCardHandleOnRead +2,2954,,InvalidGameCardHandleOnGetCardInfo +2,2960,,InvalidGameCardHandleOnOpenNormalPartition +2,2961,,InvalidGameCardHandleOnOpenSecurePartition + +2,3001,,NotImplemented +2,3002,, +2,3003,,SaveDataPathAlreadyExists +2,3005,,OutOfRange + +2,3200,3499,AllocationMemoryFailed +2,3312,,AesXtsFileFileStorageAllocationError +2,3313,,AesXtsFileXtsStorageAllocationError +2,3314,,AesXtsFileAlignmentStorageAllocationError +2,3315,,AesXtsFileStorageFileAllocationError +2,3383,,AesXtsFileSubStorageAllocationError + +2,3500,3999,MmcAccessFailed + +2,4000,4999,DataCorrupted +2,4001,4299,RomCorrupted +2,4023,,InvalidIndirectStorageSource + +2,4301,4499,SaveDataCorrupted +2,4302,, +2,4303,,InvalidSaveDataEntryType +2,4315,,InvalidSaveDataHeader +2,4362,, +2,4363,, +2,4364,,InvalidHashInSaveIvfc +2,4372,,SaveIvfcHashIsEmpty +2,4373,,InvalidHashInSaveIvfcTopLayer + +2,4402,, +2,4427,, +2,4462,,SaveDataAllocationTableCorrupted +2,4463,,SaveDataFileTableCorrupted +2,4464,,AllocationTableIteratedRangeEntry + +2,4501,4599,NcaCorrupted + +2,4601,4639,IntegrityVerificationStorageCorrupted +2,4602,, +2,4603,, +2,4604,,InvalidHashInIvfc +2,4612,,IvfcHashIsEmpty +2,4613,,InvalidHashInIvfcTopLayer + +2,4641,4659,PartitionFileSystemCorrupted +2,4642,,InvalidPartitionFileSystemHashOffset +2,4643,,InvalidPartitionFileSystemHash +2,4644,,InvalidPartitionFileSystemMagic +2,4645,,InvalidHashedPartitionFileSystemMagic +2,4646,,InvalidPartitionFileSystemEntryNameOffset + +2,4661,4679,BuiltInStorageCorrupted +2,4662,, + +2,4681,4699,FatFileSystemCorrupted +2,4701,4719,HostFileSystemCorrupted + +2,4721,4739,DatabaseCorrupted +2,4722,,SaveDataAllocationTableCorruptedInternal +2,4723,,SaveDataFileTableCorruptedInternal +2,4724,,AllocationTableIteratedRangeEntryInternal + +2,4741,4759,AesXtsFileSystemCorrupted +2,4742,,AesXtsFileHeaderTooShort +2,4743,,AesXtsFileHeaderInvalidKeys +2,4744,,AesXtsFileHeaderInvalidMagic +2,4745,,AesXtsFileTooShort +2,4746,,AesXtsFileHeaderTooShortInSetSize +2,4747,,AesXtsFileHeaderInvalidKeysInRenameFile +2,4748,,AesXtsFileHeaderInvalidKeysInSetSize + +2,4761,4769,SaveDataTransferDataCorrupted +2,4771,4779,SignedSystemPartitionDataCorrupted +2,4781,,GameCardLogoDataCorrupted + +2,4811,4819, +2,4812,, + +2,5000,5999,Unexpected +2,5307,,UnexpectedErrorInHostFileFlush +2,5308,,UnexpectedErrorInHostFileGetSize +2,5309,,UnknownHostFileSystemError +2,5320,,InvalidNcaMountPoint + +2,6000,,PreconditionViolation +2,6001,,InvalidArgument +2,6002,,InvalidPath +2,6003,,TooLongPath +2,6004,,InvalidCharacter +2,6005,,InvalidPathFormat +2,6006,,DirectoryUnobtainable +2,6007,,NotNormalized + +2,6030,6059,InvalidPathForOperation +2,6031,,DirectoryNotDeletable +2,6032,,DestinationIsSubPathOfSource +2,6033,,PathNotFoundInSaveDataFileTable +2,6034,,DifferentDestFileSystem + +2,6061,,InvalidOffset +2,6062,,InvalidSize +2,6063,,NullArgument +2,6065,,InvalidMountName +2,6066,,ExtensionSizeTooLarge +2,6067,,ExtensionSizeInvalid +2,6068,,ReadOldSaveDataInfoReader + +2,6080,6099,InvalidEnumValue +2,6081,,InvalidSaveDataState +2,6082,,InvalidSaveDataSpaceId + +2,6200,6299,InvalidOperationForOpenMode +2,6201,,FileExtensionWithoutOpenModeAllowAppend +2,6202,,InvalidOpenModeForRead +2,6203,,InvalidOpenModeForWrite + +2,6300,6399,UnsupportedOperation +2,6302,,SubStorageNotResizable +2,6303,,SubStorageNotResizableMiddleOfFile +2,6304,,UnsupportedOperationInMemoryStorageSetSize +2,6306,,UnsupportedOperationInFileStorageOperateRange +2,6310,,UnsupportedOperationInAesCtrExStorageWrite +2,6316,,UnsupportedOperationInHierarchicalIvfcStorageSetSize +2,6324,,UnsupportedOperationInIndirectStorageWrite +2,6325,,UnsupportedOperationInIndirectStorageSetSize +2,6350,,UnsupportedOperationInRoGameCardStorageWrite +2,6351,,UnsupportedOperationInRoGameCardStorageSetSize +2,6359,,UnsupportedOperationInConcatFsQueryEntry +2,6364,,UnsupportedOperationModifyRomFsFileSystem +2,6366,,UnsupportedOperationRomFsFileSystemGetSpace +2,6367,,UnsupportedOperationModifyRomFsFile +2,6369,,UnsupportedOperationModifyReadOnlyFileSystem +2,6371,,UnsupportedOperationReadOnlyFileSystemGetSpace +2,6372,,UnsupportedOperationModifyReadOnlyFile +2,6374,,UnsupportedOperationModifyPartitionFileSystem +2,6376,,UnsupportedOperationInPartitionFileSetSize +2,6377,,UnsupportedOperationIdInPartitionFileSystem + +2,6400,6449,PermissionDenied + +2,6452,,ExternalKeyAlreadyRegistered +2,6454,,WriteStateUnflushed +2,6457,,WritableFileOpen +2,6461,,AllocatorAlignmentViolation +2,6465,,UserNotExist + +2,6600,6699,EntryNotFound +2,6700,6799,OutOfResource +2,6706,,MappingTableFull +2,6707,,AllocationTableInsufficientFreeBlocks +2,6709,,OpenCountLimit + +2,6800,6899,MappingFailed +2,6811,,RemapStorageMapFull + +2,6900,6999,BadState +2,6902,,SubStorageNotInitialized +2,6905,,NotMounted +2,6906,,SaveDataIsExtending + +20,1,,TooLargeKeyOrDbFull +20,2,,KeyNotFound +20,4,,AllocationFailed +20,5,,InvalidKeyValue +20,6,,BufferInsufficient + +24,1,,DeviceNotFound +24,4,,DeviceAsleep \ No newline at end of file diff --git a/build/_build.csproj b/build/_build.csproj index fc171fc0..a5b96802 100644 --- a/build/_build.csproj +++ b/build/_build.csproj @@ -11,6 +11,7 @@ + @@ -20,6 +21,7 @@ + diff --git a/src/LibHac/Fs/ResultFs.cs b/src/LibHac/Fs/ResultFs.cs index c6bcd284..a4d5366b 100644 --- a/src/LibHac/Fs/ResultFs.cs +++ b/src/LibHac/Fs/ResultFs.cs @@ -16,45 +16,36 @@ namespace LibHac.Fs public static Result.Base InsufficientFreeSpaceBisSafe => new Result.Base(ModuleFs, 36); public static Result.Base InsufficientFreeSpaceBisUser => new Result.Base(ModuleFs, 37); public static Result.Base InsufficientFreeSpaceBisSystem => new Result.Base(ModuleFs, 38); - public static Result.Base InsufficientFreeSpaceSdCard => new Result.Base(ModuleFs, 38); + public static Result.Base InsufficientFreeSpaceSdCard => new Result.Base(ModuleFs, 39); public static Result.Base MountNameAlreadyExists => new Result.Base(ModuleFs, 60); - public static Result.Base PartitionNotFound => new Result.Base(ModuleFs, 1001); public static Result.Base TargetNotFound => new Result.Base(ModuleFs, 1002); public static Result.Base ExternalKeyNotFound => new Result.Base(ModuleFs, 1004); - public static Result.Base SdCardAccessFailed { [MethodImpl(MethodImplOptions.AggressiveInlining)] get => new Result.Base(ModuleFs, 2000, 2499); } public static Result.Base SdCardNotFound => new Result.Base(ModuleFs, 2001); public static Result.Base SdCardAsleep => new Result.Base(ModuleFs, 2004); - public static Result.Base GameCardAccessFailed { [MethodImpl(MethodImplOptions.AggressiveInlining)] get => new Result.Base(ModuleFs, 2500, 2999); } public static Result.Base InvalidBufferForGameCard => new Result.Base(ModuleFs, 2503); public static Result.Base GameCardNotInserted => new Result.Base(ModuleFs, 2520); - public static Result.Base GameCardNotInsertedOnGetHandle => new Result.Base(ModuleFs, 2951); public static Result.Base InvalidGameCardHandleOnRead => new Result.Base(ModuleFs, 2952); public static Result.Base InvalidGameCardHandleOnGetCardInfo => new Result.Base(ModuleFs, 2954); public static Result.Base InvalidGameCardHandleOnOpenNormalPartition => new Result.Base(ModuleFs, 2960); public static Result.Base InvalidGameCardHandleOnOpenSecurePartition => new Result.Base(ModuleFs, 2961); - public static Result.Base NotImplemented => new Result.Base(ModuleFs, 3001); public static Result.Base Result3002 => new Result.Base(ModuleFs, 3002); public static Result.Base SaveDataPathAlreadyExists => new Result.Base(ModuleFs, 3003); public static Result.Base OutOfRange => new Result.Base(ModuleFs, 3005); - public static Result.Base AllocationMemoryFailed { [MethodImpl(MethodImplOptions.AggressiveInlining)] get => new Result.Base(ModuleFs, 3200, 3499); } public static Result.Base AesXtsFileFileStorageAllocationError => new Result.Base(ModuleFs, 3312); public static Result.Base AesXtsFileXtsStorageAllocationError => new Result.Base(ModuleFs, 3313); public static Result.Base AesXtsFileAlignmentStorageAllocationError => new Result.Base(ModuleFs, 3314); public static Result.Base AesXtsFileStorageFileAllocationError => new Result.Base(ModuleFs, 3315); public static Result.Base AesXtsFileSubStorageAllocationError => new Result.Base(ModuleFs, 3383); - public static Result.Base MmcAccessFailed { [MethodImpl(MethodImplOptions.AggressiveInlining)] get => new Result.Base(ModuleFs, 3500, 3999); } - public static Result.Base DataCorrupted { [MethodImpl(MethodImplOptions.AggressiveInlining)] get => new Result.Base(ModuleFs, 4000, 4999); } public static Result.Base RomCorrupted { [MethodImpl(MethodImplOptions.AggressiveInlining)] get => new Result.Base(ModuleFs, 4001, 4299); } public static Result.Base InvalidIndirectStorageSource => new Result.Base(ModuleFs, 4023); - public static Result.Base SaveDataCorrupted { [MethodImpl(MethodImplOptions.AggressiveInlining)] get => new Result.Base(ModuleFs, 4301, 4499); } public static Result.Base Result4302 => new Result.Base(ModuleFs, 4302); public static Result.Base InvalidSaveDataEntryType => new Result.Base(ModuleFs, 4303); @@ -64,40 +55,32 @@ namespace LibHac.Fs public static Result.Base InvalidHashInSaveIvfc => new Result.Base(ModuleFs, 4364); public static Result.Base SaveIvfcHashIsEmpty => new Result.Base(ModuleFs, 4372); public static Result.Base InvalidHashInSaveIvfcTopLayer => new Result.Base(ModuleFs, 4373); - public static Result.Base Result4402 => new Result.Base(ModuleFs, 4402); public static Result.Base Result4427 => new Result.Base(ModuleFs, 4427); public static Result.Base SaveDataAllocationTableCorrupted => new Result.Base(ModuleFs, 4462); public static Result.Base SaveDataFileTableCorrupted => new Result.Base(ModuleFs, 4463); public static Result.Base AllocationTableIteratedRangeEntry => new Result.Base(ModuleFs, 4464); - public static Result.Base NcaCorrupted { [MethodImpl(MethodImplOptions.AggressiveInlining)] get => new Result.Base(ModuleFs, 4501, 4599); } - public static Result.Base IntegrityVerificationStorageCorrupted { [MethodImpl(MethodImplOptions.AggressiveInlining)] get => new Result.Base(ModuleFs, 4601, 4639); } public static Result.Base Result4602 => new Result.Base(ModuleFs, 4602); public static Result.Base Result4603 => new Result.Base(ModuleFs, 4603); public static Result.Base InvalidHashInIvfc => new Result.Base(ModuleFs, 4604); public static Result.Base IvfcHashIsEmpty => new Result.Base(ModuleFs, 4612); public static Result.Base InvalidHashInIvfcTopLayer => new Result.Base(ModuleFs, 4613); - public static Result.Base PartitionFileSystemCorrupted { [MethodImpl(MethodImplOptions.AggressiveInlining)] get => new Result.Base(ModuleFs, 4641, 4659); } public static Result.Base InvalidPartitionFileSystemHashOffset => new Result.Base(ModuleFs, 4642); public static Result.Base InvalidPartitionFileSystemHash => new Result.Base(ModuleFs, 4643); public static Result.Base InvalidPartitionFileSystemMagic => new Result.Base(ModuleFs, 4644); public static Result.Base InvalidHashedPartitionFileSystemMagic => new Result.Base(ModuleFs, 4645); public static Result.Base InvalidPartitionFileSystemEntryNameOffset => new Result.Base(ModuleFs, 4646); - public static Result.Base BuiltInStorageCorrupted { [MethodImpl(MethodImplOptions.AggressiveInlining)] get => new Result.Base(ModuleFs, 4661, 4679); } public static Result.Base Result4662 => new Result.Base(ModuleFs, 4662); - public static Result.Base FatFileSystemCorrupted { [MethodImpl(MethodImplOptions.AggressiveInlining)] get => new Result.Base(ModuleFs, 4681, 4699); } public static Result.Base HostFileSystemCorrupted { [MethodImpl(MethodImplOptions.AggressiveInlining)] get => new Result.Base(ModuleFs, 4701, 4719); } - public static Result.Base DatabaseCorrupted { [MethodImpl(MethodImplOptions.AggressiveInlining)] get => new Result.Base(ModuleFs, 4721, 4739); } public static Result.Base SaveDataAllocationTableCorruptedInternal => new Result.Base(ModuleFs, 4722); public static Result.Base SaveDataFileTableCorruptedInternal => new Result.Base(ModuleFs, 4723); public static Result.Base AllocationTableIteratedRangeEntryInternal => new Result.Base(ModuleFs, 4724); - public static Result.Base AesXtsFileSystemCorrupted { [MethodImpl(MethodImplOptions.AggressiveInlining)] get => new Result.Base(ModuleFs, 4741, 4759); } public static Result.Base AesXtsFileHeaderTooShort => new Result.Base(ModuleFs, 4742); public static Result.Base AesXtsFileHeaderInvalidKeys => new Result.Base(ModuleFs, 4743); @@ -106,23 +89,16 @@ namespace LibHac.Fs public static Result.Base AesXtsFileHeaderTooShortInSetSize => new Result.Base(ModuleFs, 4746); public static Result.Base AesXtsFileHeaderInvalidKeysInRenameFile => new Result.Base(ModuleFs, 4747); public static Result.Base AesXtsFileHeaderInvalidKeysInSetSize => new Result.Base(ModuleFs, 4748); - public static Result.Base SaveDataTransferDataCorrupted { [MethodImpl(MethodImplOptions.AggressiveInlining)] get => new Result.Base(ModuleFs, 4761, 4769); } public static Result.Base SignedSystemPartitionDataCorrupted { [MethodImpl(MethodImplOptions.AggressiveInlining)] get => new Result.Base(ModuleFs, 4771, 4779); } - public static Result.Base GameCardLogoDataCorrupted => new Result.Base(ModuleFs, 4781); - public static Result.Base Range4811To4819 { [MethodImpl(MethodImplOptions.AggressiveInlining)] get => new Result.Base(ModuleFs, 4811, 4819); } public static Result.Base Result4812 => new Result.Base(ModuleFs, 4812); - public static Result.Base Unexpected { [MethodImpl(MethodImplOptions.AggressiveInlining)] get => new Result.Base(ModuleFs, 5000, 5999); } - public static Result.Base UnexpectedErrorInHostFileFlush => new Result.Base(ModuleFs, 5307); public static Result.Base UnexpectedErrorInHostFileGetSize => new Result.Base(ModuleFs, 5308); public static Result.Base UnknownHostFileSystemError => new Result.Base(ModuleFs, 5309); - public static Result.Base InvalidNcaMountPoint => new Result.Base(ModuleFs, 5320); - public static Result.Base PreconditionViolation => new Result.Base(ModuleFs, 6000); public static Result.Base InvalidArgument => new Result.Base(ModuleFs, 6001); public static Result.Base InvalidPath => new Result.Base(ModuleFs, 6002); @@ -131,13 +107,11 @@ namespace LibHac.Fs public static Result.Base InvalidPathFormat => new Result.Base(ModuleFs, 6005); public static Result.Base DirectoryUnobtainable => new Result.Base(ModuleFs, 6006); public static Result.Base NotNormalized => new Result.Base(ModuleFs, 6007); - public static Result.Base InvalidPathForOperation { [MethodImpl(MethodImplOptions.AggressiveInlining)] get => new Result.Base(ModuleFs, 6030, 6059); } public static Result.Base DirectoryNotDeletable => new Result.Base(ModuleFs, 6031); public static Result.Base DestinationIsSubPathOfSource => new Result.Base(ModuleFs, 6032); public static Result.Base PathNotFoundInSaveDataFileTable => new Result.Base(ModuleFs, 6033); public static Result.Base DifferentDestFileSystem => new Result.Base(ModuleFs, 6034); - public static Result.Base InvalidOffset => new Result.Base(ModuleFs, 6061); public static Result.Base InvalidSize => new Result.Base(ModuleFs, 6062); public static Result.Base NullArgument => new Result.Base(ModuleFs, 6063); @@ -145,16 +119,13 @@ namespace LibHac.Fs public static Result.Base ExtensionSizeTooLarge => new Result.Base(ModuleFs, 6066); public static Result.Base ExtensionSizeInvalid => new Result.Base(ModuleFs, 6067); public static Result.Base ReadOldSaveDataInfoReader => new Result.Base(ModuleFs, 6068); - public static Result.Base InvalidEnumValue { [MethodImpl(MethodImplOptions.AggressiveInlining)] get => new Result.Base(ModuleFs, 6080, 6099); } public static Result.Base InvalidSaveDataState => new Result.Base(ModuleFs, 6081); public static Result.Base InvalidSaveDataSpaceId => new Result.Base(ModuleFs, 6082); - public static Result.Base InvalidOperationForOpenMode { [MethodImpl(MethodImplOptions.AggressiveInlining)] get => new Result.Base(ModuleFs, 6200, 6299); } public static Result.Base FileExtensionWithoutOpenModeAllowAppend => new Result.Base(ModuleFs, 6201); public static Result.Base InvalidOpenModeForRead => new Result.Base(ModuleFs, 6202); public static Result.Base InvalidOpenModeForWrite => new Result.Base(ModuleFs, 6203); - public static Result.Base UnsupportedOperation { [MethodImpl(MethodImplOptions.AggressiveInlining)] get => new Result.Base(ModuleFs, 6300, 6399); } public static Result.Base SubStorageNotResizable => new Result.Base(ModuleFs, 6302); public static Result.Base SubStorageNotResizableMiddleOfFile => new Result.Base(ModuleFs, 6303); @@ -176,25 +147,19 @@ namespace LibHac.Fs public static Result.Base UnsupportedOperationModifyPartitionFileSystem => new Result.Base(ModuleFs, 6374); public static Result.Base UnsupportedOperationInPartitionFileSetSize => new Result.Base(ModuleFs, 6376); public static Result.Base UnsupportedOperationIdInPartitionFileSystem => new Result.Base(ModuleFs, 6377); - public static Result.Base PermissionDenied { [MethodImpl(MethodImplOptions.AggressiveInlining)] get => new Result.Base(ModuleFs, 6400, 6449); } - public static Result.Base ExternalKeyAlreadyRegistered => new Result.Base(ModuleFs, 6452); public static Result.Base WriteStateUnflushed => new Result.Base(ModuleFs, 6454); public static Result.Base WritableFileOpen => new Result.Base(ModuleFs, 6457); public static Result.Base AllocatorAlignmentViolation => new Result.Base(ModuleFs, 6461); public static Result.Base UserNotExist => new Result.Base(ModuleFs, 6465); - public static Result.Base EntryNotFound { [MethodImpl(MethodImplOptions.AggressiveInlining)] get => new Result.Base(ModuleFs, 6600, 6699); } - public static Result.Base OutOfResource { [MethodImpl(MethodImplOptions.AggressiveInlining)] get => new Result.Base(ModuleFs, 6700, 6799); } public static Result.Base MappingTableFull => new Result.Base(ModuleFs, 6706); public static Result.Base AllocationTableInsufficientFreeBlocks => new Result.Base(ModuleFs, 6707); public static Result.Base OpenCountLimit => new Result.Base(ModuleFs, 6709); - public static Result.Base MappingFailed { [MethodImpl(MethodImplOptions.AggressiveInlining)] get => new Result.Base(ModuleFs, 6800, 6899); } public static Result.Base RemapStorageMapFull => new Result.Base(ModuleFs, 6811); - public static Result.Base BadState { [MethodImpl(MethodImplOptions.AggressiveInlining)] get => new Result.Base(ModuleFs, 6900, 6999); } public static Result.Base SubStorageNotInitialized => new Result.Base(ModuleFs, 6902); public static Result.Base NotMounted => new Result.Base(ModuleFs, 6905);