mirror of
https://github.com/dcronqvist/DotTiled.git
synced 2025-05-08 16:06:03 +03:00
ZStd Support
This commit is contained in:
parent
4e735ad8f3
commit
2388af6b52
4 changed files with 9 additions and 2 deletions
|
@ -46,6 +46,12 @@ internal static partial class Helpers
|
|||
return ReadMemoryStreamAsInt32Array(decompressedStream);
|
||||
}
|
||||
|
||||
internal static uint[] DecompressZStd(MemoryStream stream)
|
||||
{
|
||||
using var decompressedStream = new ZstdSharp.DecompressionStream(stream);
|
||||
return ReadMemoryStreamAsInt32Array(decompressedStream);
|
||||
}
|
||||
|
||||
internal static uint[] ReadBytesAsInt32Array(byte[] bytes)
|
||||
{
|
||||
var intArray = new uint[bytes.Length / 4];
|
||||
|
|
|
@ -61,7 +61,7 @@ public abstract partial class TmjReaderBase
|
|||
{
|
||||
DataCompression.GZip => Helpers.DecompressGZip(stream),
|
||||
DataCompression.ZLib => Helpers.DecompressZLib(stream),
|
||||
DataCompression.ZStd => throw new NotSupportedException("ZStd compression is not supported."),
|
||||
DataCompression.ZStd => Helpers.DecompressZStd(stream),
|
||||
_ => throw new InvalidOperationException($"Unsupported compression '{compression}'.")
|
||||
};
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ public abstract partial class TmjReaderBase
|
|||
{
|
||||
"zlib" => DataCompression.ZLib,
|
||||
"gzip" => DataCompression.GZip,
|
||||
"zstd" => DataCompression.ZStd,
|
||||
"" => Optional.Empty,
|
||||
_ => throw new JsonException($"Unsupported compression '{s}'.")
|
||||
});
|
||||
|
|
|
@ -77,7 +77,7 @@ public abstract partial class TmxReaderBase
|
|||
{
|
||||
DataCompression.GZip => Helpers.DecompressGZip(bytes),
|
||||
DataCompression.ZLib => Helpers.DecompressZLib(bytes),
|
||||
DataCompression.ZStd => throw new NotSupportedException("ZStd compression is not supported."),
|
||||
DataCompression.ZStd => Helpers.DecompressZStd(bytes),
|
||||
_ => throw new XmlException("Invalid compression")
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue