Skip to content

Commit

Permalink
Add GetDecompressedSize method
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchLeaders committed Apr 14, 2024
1 parent 5a273fc commit 7ea4dde
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/CsYaz0/Yaz0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@ public static DataMarshal Compress(ReadOnlySpan<byte> src, uint alignment = 0, i
}
}

public static int GetDecompressedSize(ReadOnlySpan<byte> data)
{
return BinaryPrimitives.ReverseEndianness(MemoryMarshal.Read<int>(data[4..8]));
}

public static byte[] Decompress(ReadOnlySpan<byte> data)
{
uint bufferSize = BinaryPrimitives.ReverseEndianness(MemoryMarshal.Read<uint>(data[4..8]));
byte[] result = new byte[bufferSize];
byte[] result = new byte[GetDecompressedSize(data)];
Decompress(data, result);
return result;
}
Expand Down

0 comments on commit 7ea4dde

Please sign in to comment.