Move NcaUtils

This commit is contained in:
Alex Barney 2021-12-18 19:43:06 -07:00
parent 7681429c97
commit aa153980be
21 changed files with 78 additions and 74 deletions

View file

@ -1,7 +1,7 @@
using LibHac.Common; using LibHac.Common;
using LibHac.Fs; using LibHac.Fs;
using LibHac.Fs.Fsa; using LibHac.Fs.Fsa;
using LibHac.FsSystem.NcaUtils; using LibHac.Tools.FsSystem.NcaUtils;
namespace LibHac.FsSrv.FsCreator; namespace LibHac.FsSrv.FsCreator;

View file

@ -5,7 +5,7 @@ using LibHac.Fs;
using LibHac.Fs.Fsa; using LibHac.Fs.Fsa;
using LibHac.FsSystem; using LibHac.FsSystem;
using LibHac.FsSystem.Impl; using LibHac.FsSystem.Impl;
using LibHac.FsSystem.NcaUtils; using LibHac.Tools.FsSystem.NcaUtils;
namespace LibHac.FsSrv.FsCreator; namespace LibHac.FsSrv.FsCreator;

View file

@ -8,10 +8,10 @@ using LibHac.Fs.Fsa;
using LibHac.FsSrv.FsCreator; using LibHac.FsSrv.FsCreator;
using LibHac.FsSrv.Impl; using LibHac.FsSrv.Impl;
using LibHac.FsSystem; using LibHac.FsSystem;
using LibHac.FsSystem.NcaUtils;
using LibHac.Ncm; using LibHac.Ncm;
using LibHac.Os; using LibHac.Os;
using LibHac.Spl; using LibHac.Spl;
using LibHac.Tools.FsSystem.NcaUtils;
using LibHac.Util; using LibHac.Util;
using RightsId = LibHac.Fs.RightsId; using RightsId = LibHac.Fs.RightsId;
using Utility = LibHac.FsSystem.Utility; using Utility = LibHac.FsSystem.Utility;

View file

@ -2,41 +2,7 @@
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using LibHac.Common.FixedArrays; using LibHac.Common.FixedArrays;
namespace LibHac.FsSystem.NcaUtils; namespace LibHac.FsSystem;
public class TitleVersion
{
public uint Version { get; }
public int Major { get; }
public int Minor { get; }
public int Patch { get; }
public int Revision { get; }
public TitleVersion(uint version, bool isSystemTitle = false)
{
Version = version;
if (isSystemTitle)
{
Revision = (int)(version & ((1 << 16) - 1));
Patch = (int)((version >> 16) & ((1 << 4) - 1));
Minor = (int)((version >> 20) & ((1 << 6) - 1));
Major = (int)((version >> 26) & ((1 << 6) - 1));
}
else
{
Revision = (byte)version;
Patch = (byte)(version >> 8);
Minor = (byte)(version >> 16);
Major = (byte)(version >> 24);
}
}
public override string ToString()
{
return $"{Major}.{Minor}.{Patch}.{Revision}";
}
}
public struct NcaSparseInfo public struct NcaSparseInfo
{ {

View file

@ -8,9 +8,9 @@ using LibHac.Common.Keys;
using LibHac.Fs; using LibHac.Fs;
using LibHac.Fs.Fsa; using LibHac.Fs.Fsa;
using LibHac.FsSystem; using LibHac.FsSystem;
using LibHac.FsSystem.NcaUtils;
using LibHac.Ncm; using LibHac.Ncm;
using LibHac.Ns; using LibHac.Ns;
using LibHac.Tools.FsSystem.NcaUtils;
using LibHac.Tools.FsSystem.Save; using LibHac.Tools.FsSystem.Save;
using LibHac.Tools.Ncm; using LibHac.Tools.Ncm;
using LibHac.Util; using LibHac.Util;

View file

@ -9,10 +9,11 @@ using LibHac.Crypto;
using LibHac.Diag; using LibHac.Diag;
using LibHac.Fs; using LibHac.Fs;
using LibHac.Fs.Fsa; using LibHac.Fs.Fsa;
using LibHac.FsSystem;
using LibHac.FsSystem.RomFs; using LibHac.FsSystem.RomFs;
using LibHac.Spl; using LibHac.Spl;
namespace LibHac.FsSystem.NcaUtils; namespace LibHac.Tools.FsSystem.NcaUtils;
public class Nca public class Nca
{ {
@ -778,7 +779,7 @@ public class Nca
return Header.VerifySignature1(KeySet.NcaHeaderSigningKeyParams[0].Modulus); return Header.VerifySignature1(KeySet.NcaHeaderSigningKeyParams[0].Modulus);
} }
internal void GenerateAesCounter(int sectionIndex, Ncm.ContentType type, int minorVersion) internal void GenerateAesCounter(int sectionIndex, LibHac.Ncm.ContentType type, int minorVersion)
{ {
int counterType; int counterType;
int counterVersion; int counterVersion;
@ -789,14 +790,14 @@ public class Nca
switch (type) switch (type)
{ {
case Ncm.ContentType.Program: case LibHac.Ncm.ContentType.Program:
counterType = sectionIndex + 1; counterType = sectionIndex + 1;
break; break;
case Ncm.ContentType.HtmlDocument: case LibHac.Ncm.ContentType.HtmlDocument:
counterType = (int)Ncm.ContentType.HtmlDocument; counterType = (int)LibHac.Ncm.ContentType.HtmlDocument;
break; break;
case Ncm.ContentType.LegalInformation: case LibHac.Ncm.ContentType.LegalInformation:
counterType = (int)Ncm.ContentType.LegalInformation; counterType = (int)LibHac.Ncm.ContentType.LegalInformation;
break; break;
default: default:
counterType = 0; counterType = 0;

View file

@ -4,8 +4,9 @@ using System.Diagnostics;
using LibHac.Crypto; using LibHac.Crypto;
using LibHac.Fs; using LibHac.Fs;
using LibHac.Fs.Fsa; using LibHac.Fs.Fsa;
using LibHac.FsSystem;
namespace LibHac.FsSystem.NcaUtils; namespace LibHac.Tools.FsSystem.NcaUtils;
public static class NcaExtensions public static class NcaExtensions
{ {

View file

@ -1,10 +1,11 @@
using System; using System;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using LibHac.FsSystem;
// ReSharper disable ImpureMethodCallOnReadonlyValueField // ReSharper disable ImpureMethodCallOnReadonlyValueField
namespace LibHac.FsSystem.NcaUtils; namespace LibHac.Tools.FsSystem.NcaUtils;
public struct NcaFsHeader public struct NcaFsHeader
{ {

View file

@ -2,7 +2,7 @@
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace LibHac.FsSystem.NcaUtils; namespace LibHac.Tools.FsSystem.NcaUtils;
public struct NcaFsIntegrityInfoIvfc public struct NcaFsIntegrityInfoIvfc
{ {

View file

@ -2,7 +2,7 @@
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace LibHac.FsSystem.NcaUtils; namespace LibHac.Tools.FsSystem.NcaUtils;
public struct NcaFsIntegrityInfoSha256 public struct NcaFsIntegrityInfoSha256
{ {

View file

@ -2,7 +2,7 @@
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace LibHac.FsSystem.NcaUtils; namespace LibHac.Tools.FsSystem.NcaUtils;
public struct NcaFsPatchInfo public struct NcaFsPatchInfo
{ {

View file

@ -7,9 +7,10 @@ using LibHac.Common.Keys;
using LibHac.Crypto; using LibHac.Crypto;
using LibHac.Diag; using LibHac.Diag;
using LibHac.Fs; using LibHac.Fs;
using LibHac.FsSystem;
using LibHac.Util; using LibHac.Util;
namespace LibHac.FsSystem.NcaUtils; namespace LibHac.Tools.FsSystem.NcaUtils;
public struct NcaHeader public struct NcaHeader
{ {

View file

@ -1,4 +1,4 @@
namespace LibHac.FsSystem.NcaUtils; namespace LibHac.Tools.FsSystem.NcaUtils;
internal enum NcaKeyType internal enum NcaKeyType
{ {

View file

@ -0,0 +1,35 @@
namespace LibHac.Tools.FsSystem.NcaUtils;
public class TitleVersion
{
public uint Version { get; }
public int Major { get; }
public int Minor { get; }
public int Patch { get; }
public int Revision { get; }
public TitleVersion(uint version, bool isSystemTitle = false)
{
Version = version;
if (isSystemTitle)
{
Revision = (int)(version & ((1 << 16) - 1));
Patch = (int)((version >> 16) & ((1 << 4) - 1));
Minor = (int)((version >> 20) & ((1 << 6) - 1));
Major = (int)((version >> 26) & ((1 << 6) - 1));
}
else
{
Revision = (byte)version;
Patch = (byte)(version >> 8);
Minor = (byte)(version >> 16);
Major = (byte)(version >> 24);
}
}
public override string ToString()
{
return $"{Major}.{Minor}.{Patch}.{Revision}";
}
}

View file

@ -1,7 +1,7 @@
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using LibHac.FsSystem.NcaUtils;
using LibHac.Ncm; using LibHac.Ncm;
using LibHac.Tools.FsSystem.NcaUtils;
using ContentType = LibHac.Ncm.ContentType; using ContentType = LibHac.Ncm.ContentType;
namespace LibHac.Tools.Ncm; namespace LibHac.Tools.Ncm;

View file

@ -1,6 +1,6 @@
using LibHac; using LibHac;
using LibHac.Fs; using LibHac.Fs;
using LibHac.FsSystem.NcaUtils; using LibHac.FsSystem;
using LibHac.Ncm; using LibHac.Ncm;
using LibHac.Tools.Fs; using LibHac.Tools.Fs;
using ContentType = LibHac.Ncm.ContentType; using ContentType = LibHac.Ncm.ContentType;

View file

@ -3,7 +3,7 @@ using System.Buffers.Binary;
using System.Text; using System.Text;
using LibHac; using LibHac;
using LibHac.FsSystem; using LibHac.FsSystem;
using LibHac.FsSystem.NcaUtils; using LibHac.Tools.FsSystem.NcaUtils;
namespace hactoolnet; namespace hactoolnet;

View file

@ -6,8 +6,8 @@ using LibHac.Common;
using LibHac.Fs; using LibHac.Fs;
using LibHac.Fs.Fsa; using LibHac.Fs.Fsa;
using LibHac.FsSystem; using LibHac.FsSystem;
using LibHac.FsSystem.NcaUtils;
using LibHac.Tools.FsSystem; using LibHac.Tools.FsSystem;
using LibHac.Tools.FsSystem.NcaUtils;
using static hactoolnet.Print; using static hactoolnet.Print;
namespace hactoolnet; namespace hactoolnet;

View file

@ -6,8 +6,8 @@ using LibHac.Fs;
using LibHac.Fs.Fsa; using LibHac.Fs.Fsa;
using LibHac.Fs.Impl; using LibHac.Fs.Impl;
using LibHac.FsSystem; using LibHac.FsSystem;
using LibHac.FsSystem.NcaUtils;
using LibHac.Npdm; using LibHac.Npdm;
using LibHac.Tools.FsSystem.NcaUtils;
using static hactoolnet.Print; using static hactoolnet.Print;
namespace hactoolnet; namespace hactoolnet;

View file

@ -8,7 +8,6 @@ using LibHac;
using LibHac.Fs; using LibHac.Fs;
using LibHac.Fs.Fsa; using LibHac.Fs.Fsa;
using LibHac.FsSystem; using LibHac.FsSystem;
using LibHac.FsSystem.NcaUtils;
using LibHac.Ns; using LibHac.Ns;
using LibHac.Tools.Fs; using LibHac.Tools.Fs;
using LibHac.Tools.FsSystem.Save; using LibHac.Tools.FsSystem.Save;

View file

@ -4,8 +4,8 @@ using System.Text;
using LibHac; using LibHac;
using LibHac.Fs; using LibHac.Fs;
using LibHac.FsSystem; using LibHac.FsSystem;
using LibHac.FsSystem.NcaUtils;
using LibHac.Tools.Fs; using LibHac.Tools.Fs;
using LibHac.Tools.FsSystem.NcaUtils;
using static hactoolnet.Print; using static hactoolnet.Print;
namespace hactoolnet; namespace hactoolnet;