pkNX/pkNX.Containers/Misc/AHTBEntry.cs
Kurt 2578ba073c Refactoring
File scoped namespaces for all lib projects
netstandard2.0 => net6; now uniform. bye netframework!
2022-10-01 17:08:17 -07:00

37 lines
894 B
C#

using System.IO;
namespace pkNX.Containers;
public class AHTBEntry
{
public ulong Hash;
public ushort NameLength;
public string Name;
public AHTBEntry(ulong hash, ushort namelen, string name)
{
Hash = hash;
NameLength = namelen;
Name = name;
}
public AHTBEntry(BinaryReader br)
{
Hash = br.ReadUInt64();
NameLength = br.ReadUInt16();
Name = br.ReadStringBytesUntil(0); // could use Length field, but they're always \0 terminated
//Debug.Assert(FnvHash.HashFnv1a_64(Name) == Hash);
//Debug.Assert(Name.Length + 1 == NameLength); // Always null terminated
}
public void Write(BinaryWriter bw)
{
bw.Write(Hash);
bw.Write(Name.Length + 1);
bw.Write(Name);
bw.Write((byte)0); // \0 terminator
}
public string Summary => $"{Hash:X16}\t{Name}";
}