Skip to content

Commit

Permalink
Added support for decoding Brotli compression used in new formats (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
Taloth authored Nov 9, 2023
1 parent c21a0d5 commit 2bb952f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
12 changes: 11 additions & 1 deletion AOEMods.Essence/SGA/Core/FileStorageType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,15 @@ public enum FileStorageType : byte
/// <summary>
/// Stored compressed.
/// </summary>
BufferCompress
BufferCompress,

/// <summary>
/// Stored compressed.
/// </summary>
StreamCompressBrotli,

/// <summary>
/// Stored compressed.
/// </summary>
BufferCompressBrotli
}
10 changes: 10 additions & 0 deletions AOEMods.Essence/SGA/Graph/ArchiveFileNode.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using AOEMods.Essence.SGA.Core;
using System.IO;
using System.IO.Compression;
using System.Text;

Expand Down Expand Up @@ -67,6 +68,15 @@ public IEnumerable<byte> GetData()
MemoryStream decoded = new((int)dataUncompressedLength);
deflateStream.CopyTo(decoded);

return decoded.ToArray();
}
case FileStorageType.StreamCompressBrotli:
case FileStorageType.BufferCompressBrotli:
{
using var brotliStream = new BrotliStream(dataStream, CompressionMode.Decompress, leaveOpen: true);
MemoryStream decoded = new((int)dataUncompressedLength);
brotliStream.CopyTo(decoded);

return decoded.ToArray();
}
default:
Expand Down

0 comments on commit 2bb952f

Please sign in to comment.