Exemplo n.º 1
0
        public void CompressStreamToChunk(MemoryStream aInput)
        {
            using (MemoryStream memoryStream = new MemoryStream()) {
                ZOutputStream zlibStream = new ZOutputStream(memoryStream, (int)CompressionMode);

                zlibStream.Write(aInput.ToArray(), 0, (int)aInput.Length);
                zlibStream.finish();
                zlibStream.end();

                Write((int)memoryStream.Length);
                memoryStream.WriteTo(BaseStream);
            }
        }
Exemplo n.º 2
0
        public void DecompressChunkToStream(MemoryStream aOutput)
        {
            var chunkPosition = BaseStream.Position + 4;
            var chunk         = ReadChunk();

            try {
                ZOutputStream zlibStream = new ZOutputStream(aOutput);
                zlibStream.Write(chunk, 0, chunk.Length);
                zlibStream.finish();
                zlibStream.end();
            }
            catch (ZStreamException e) {
                throw new Exceptions.FileCorrupted(chunkPosition, e.Message);
            }
        }