mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
39 lines
1.3 KiB
C#
39 lines
1.3 KiB
C#
using System.IO;
|
|
using System.Text;
|
|
|
|
namespace SabreTools.FileTypes.Aaru
|
|
{
|
|
/// <summary>
|
|
/// Header for the index, followed by entries
|
|
/// </summary>
|
|
/// <see cref="https://github.com/aaru-dps/Aaru/blob/master/Aaru.Images/AaruFormat/Structs.cs" />
|
|
public class IndexHeader
|
|
{
|
|
/// <summary>Identifier, <see cref="BlockType.Index" /></summary>
|
|
public AaruBlockType identifier;
|
|
/// <summary>How many entries follow this header</summary>
|
|
public ushort entries;
|
|
/// <summary>CRC64-ECMA of the index</summary>
|
|
public ulong crc64;
|
|
|
|
/// <summary>
|
|
/// Read a stream as an IndexHeader
|
|
/// </summary>
|
|
/// <param name="stream">IndexHeader as a stream</param>
|
|
/// <returns>Populated IndexHeader, null on failure</returns>
|
|
public static IndexHeader Deserialize(Stream stream)
|
|
{
|
|
var indexHeader = new IndexHeader();
|
|
|
|
using (var br = new BinaryReader(stream, Encoding.Default, true))
|
|
{
|
|
indexHeader.identifier = (AaruBlockType)br.ReadUInt32();
|
|
indexHeader.entries = br.ReadUInt16();
|
|
indexHeader.crc64 = br.ReadUInt64();
|
|
}
|
|
|
|
return indexHeader;
|
|
}
|
|
}
|
|
}
|