Add Z3DS metadata structures

This commit is contained in:
Matt Nadareski
2026-05-18 09:54:33 -04:00
parent 5ef595e01a
commit 390e39ef30
3 changed files with 72 additions and 0 deletions

View File

@@ -226,4 +226,18 @@ namespace SabreTools.Data.Models.N3DS
Optional = 0x4000,
Shared = 0x8000,
}
/// <see href="https://github.com/azahar-emu/azahar/blob/master/src/common/zstd_compression.h"/>
public enum Z3DSMetadataItemType : byte
{
/// <summary>
/// End marker
/// </summary>
End = 0,
/// <summary>
/// Binary metadata
/// </summary>
Binary = 1,
}
}

View File

@@ -0,0 +1,20 @@
namespace SabreTools.Data.Models.N3DS
{
/// <summary>
/// Metadata block whose size is defined by <see cref="Z3DSFileHeader.MetadataSize"/>
/// </summary>
/// <see href="https://github.com/azahar-emu/azahar/blob/master/src/common/zstd_compression.h"/>
public class Z3DSMetadata
{
/// <summary>
/// Metadata version
/// </summary>
/// <remarks>Currently only a value of 1 is expected</remarks>
public byte Version { get; set; }
/// <summary>
/// Set of metadata entries in the block
/// </summary>
public Z3DSMetadataItem[] Items { get; set; } = [];
}
}

View File

@@ -0,0 +1,38 @@
namespace SabreTools.Data.Models.N3DS
{
/// <summary>
/// Metadata item entry
/// </summary>
/// <see href="https://github.com/azahar-emu/azahar/blob/master/src/common/zstd_compression.h"/>
public class Z3DSMetadataItem
{
/// <summary>
/// Item type
/// </summary>
public Z3DSMetadataItemType Type { get; set; }
/// <summary>
/// Length of the name field
/// </summary>
public byte NameLength { get; set; }
/// <summary>
/// Length of the data field
/// </summary>
public ushort DataLength { get; set; }
/// <summary>
/// Name encoded as bytes whose length is given
/// by <see cref="NameLength"/>
/// </summary>
/// <remarks>Ignored if <see cref="Type"/> is End</remarks>
public byte[] Name { get; set; } = [];
/// <summary>
/// Data encoded as bytes whose length is given
/// by <see cref="DataLength"/>
/// </summary>
/// <remarks>Ignored if <see cref="Type"/> is End</remarks>
public byte[] Data { get; set; } = [];
}
}