mirror of
https://github.com/Thealexbarney/LibHac.git
synced 2024-11-14 10:49:41 +01:00
hactoolnet: Add functions to convert some enums to strings
This commit is contained in:
parent
a005b40022
commit
f2f2111729
3 changed files with 92 additions and 5 deletions
87
src/hactoolnet/EnumStrings.cs
Normal file
87
src/hactoolnet/EnumStrings.cs
Normal file
|
@ -0,0 +1,87 @@
|
|||
using LibHac;
|
||||
using LibHac.FsSystem.NcaUtils;
|
||||
using LibHac.Ncm;
|
||||
|
||||
namespace hactoolnet
|
||||
{
|
||||
internal static class EnumStrings
|
||||
{
|
||||
public static string Print(this ContentType value)
|
||||
{
|
||||
return value switch
|
||||
{
|
||||
ContentType.Meta => nameof(ContentType.Meta),
|
||||
ContentType.Program => nameof(ContentType.Program),
|
||||
ContentType.Data => nameof(ContentType.Data),
|
||||
ContentType.Control => nameof(ContentType.Control),
|
||||
ContentType.HtmlDocument => nameof(ContentType.HtmlDocument),
|
||||
ContentType.LegalInformation => nameof(ContentType.LegalInformation),
|
||||
ContentType.DeltaFragment => nameof(ContentType.DeltaFragment),
|
||||
_ => value.ToString()
|
||||
};
|
||||
}
|
||||
|
||||
public static string Print(this ContentMetaType value)
|
||||
{
|
||||
return value switch
|
||||
{
|
||||
ContentMetaType.SystemProgram => nameof(ContentMetaType.SystemProgram),
|
||||
ContentMetaType.SystemData => nameof(ContentMetaType.SystemData),
|
||||
ContentMetaType.SystemUpdate => nameof(ContentMetaType.SystemUpdate),
|
||||
ContentMetaType.BootImagePackage => nameof(ContentMetaType.BootImagePackage),
|
||||
ContentMetaType.BootImagePackageSafe => nameof(ContentMetaType.BootImagePackageSafe),
|
||||
ContentMetaType.Application => nameof(ContentMetaType.Application),
|
||||
ContentMetaType.Patch => nameof(ContentMetaType.Patch),
|
||||
ContentMetaType.AddOnContent => nameof(ContentMetaType.AddOnContent),
|
||||
ContentMetaType.Delta => nameof(ContentMetaType.Delta),
|
||||
_ => value.ToString()
|
||||
};
|
||||
}
|
||||
|
||||
public static string Print(this DistributionType value)
|
||||
{
|
||||
return value switch
|
||||
{
|
||||
DistributionType.Download => nameof(DistributionType.Download),
|
||||
DistributionType.GameCard => nameof(DistributionType.GameCard),
|
||||
_ => value.ToString()
|
||||
};
|
||||
}
|
||||
|
||||
public static string Print(this NcaContentType value)
|
||||
{
|
||||
return value switch
|
||||
{
|
||||
NcaContentType.Program => nameof(NcaContentType.Program),
|
||||
NcaContentType.Meta => nameof(NcaContentType.Meta),
|
||||
NcaContentType.Control => nameof(NcaContentType.Control),
|
||||
NcaContentType.Manual => nameof(NcaContentType.Manual),
|
||||
NcaContentType.Data => nameof(NcaContentType.Data),
|
||||
NcaContentType.PublicData => nameof(NcaContentType.PublicData),
|
||||
_ => value.ToString()
|
||||
};
|
||||
}
|
||||
|
||||
public static string Print(this NcaFormatType value)
|
||||
{
|
||||
return value switch
|
||||
{
|
||||
NcaFormatType.Romfs => nameof(NcaFormatType.Romfs),
|
||||
NcaFormatType.Pfs0 => nameof(NcaFormatType.Pfs0),
|
||||
_ => value.ToString()
|
||||
};
|
||||
}
|
||||
|
||||
public static string Print(this Validity value)
|
||||
{
|
||||
return value switch
|
||||
{
|
||||
Validity.Unchecked => nameof(Validity.Unchecked),
|
||||
Validity.Invalid => nameof(Validity.Invalid),
|
||||
Validity.Valid => nameof(Validity.Valid),
|
||||
Validity.MissingKey => nameof(Validity.MissingKey),
|
||||
_ => value.ToString()
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
|
@ -250,8 +250,8 @@ namespace hactoolnet
|
|||
}
|
||||
|
||||
PrintItem(sb, colLen, "SDK Version:", nca.Header.SdkVersion);
|
||||
PrintItem(sb, colLen, "Distribution type:", nca.Header.DistributionType);
|
||||
PrintItem(sb, colLen, "Content Type:", nca.Header.ContentType);
|
||||
PrintItem(sb, colLen, "Distribution type:", nca.Header.DistributionType.Print());
|
||||
PrintItem(sb, colLen, "Content Type:", nca.Header.ContentType.Print());
|
||||
PrintItem(sb, colLen, "Master Key Revision:", $"{masterKey} ({Utilities.GetKeyRevisionSummary(masterKey)})");
|
||||
PrintItem(sb, colLen, "Encryption Type:", $"{(nca.Header.HasRightsId ? "Titlekey crypto" : "Standard crypto")}");
|
||||
|
||||
|
@ -326,7 +326,7 @@ namespace hactoolnet
|
|||
PrintItem(sb, colLen, " Size:", $"0x{nca.Header.GetSectionSize(i):x12}");
|
||||
PrintItem(sb, colLen, " Partition Type:", GetPartitionType(sectHeader, isExefs, nca.Header.IsNca0()));
|
||||
PrintItem(sb, colLen, " Section CTR:", $"{sectHeader.Counter:x16}");
|
||||
PrintItem(sb, colLen, " Section Validity:", $"{ncaHolder.Validities[i]}");
|
||||
PrintItem(sb, colLen, " Section Validity:", $"{ncaHolder.Validities[i].Print()}");
|
||||
|
||||
switch (sectHeader.HashType)
|
||||
{
|
||||
|
@ -350,7 +350,7 @@ namespace hactoolnet
|
|||
if (isExefs) return "ExeFS";
|
||||
if (isNca0 && fsHeader.FormatType == NcaFormatType.Romfs) return "NCA0 RomFS";
|
||||
|
||||
return fsHeader.FormatType + (fsHeader.IsPatchSection() ? " patch" : "");
|
||||
return fsHeader.FormatType.Print() + (fsHeader.IsPatchSection() ? " patch" : "");
|
||||
}
|
||||
|
||||
void PrintSha256Hash(NcaFsHeader sect, int index)
|
||||
|
|
|
@ -241,7 +241,7 @@ namespace hactoolnet
|
|||
table.AddRow($"{title.Id:X16}",
|
||||
$"v{title.Version?.Version}",
|
||||
title.Version?.ToString(),
|
||||
title.Metadata?.Type.ToString(),
|
||||
title.Metadata?.Type.Print(),
|
||||
Utilities.GetBytesReadable(title.GetSize()),
|
||||
title.Control.Value.DisplayVersion.ToString(),
|
||||
title.Name);
|
||||
|
|
Loading…
Reference in a new issue