ImaginaryDevelopment / imaginary-hero-designer

Mid's Hero Designer reborn with Pine's help
GNU General Public License v3.0
25 stars 15 forks source link

consider switching out zlib for SharpZipLib #87

Open patrickhuber opened 5 years ago

patrickhuber commented 5 years ago

The dependency on zlib uses a c library which lacks a managed interface and regular updates that can be achieved with a nuget package of SharpZipLib.

I implemented a proof of concept decoding the hex codes of www.cityofheroesplanner.com in my data export library here:

Code under test here:

Its pretty simple to get it setup:

install SharpZipLib

install-package SharpZipLib

Create a stream around an existing byte stream (like the hex stream from the encoded build urls)

var encoded = Encoding.ASCII.GetBytes(data.EncodedString);
var decodedBytes = HexUtil.Decode(encoded);
var compressedStream = new MemoryStream(decodedBytes);
_internalStream = new InflaterInputStream(compressedStream);

Read from the internal stream like you would any other stream. For example, wrapping it in a BinaryReader. I happened to encapsulate it in a wrapper class so I could avoid the boiler plate code for setting it up.