Example #1
0
 /// <exception cref="System.IO.IOException"/>
 private byte[] Decompress(byte[] data, bool byByte)
 {
     byte[] buffer = new byte[65536];
     System.IO.MemoryStream           input       = new System.IO.MemoryStream(data);
     System.IO.MemoryStream           output      = new System.IO.MemoryStream();
     Org.Brotli.Dec.BrotliInputStream brotliInput = new Org.Brotli.Dec.BrotliInputStream(input);
     if (byByte)
     {
         byte[] oneByte = new byte[1];
         while (true)
         {
             int next = brotliInput.ReadByte();
             if (next == -1)
             {
                 break;
             }
             oneByte[0] = unchecked ((byte)next);
             output.Write(oneByte, 0, 1);
         }
     }
     else
     {
         while (true)
         {
             int len = brotliInput.Read(buffer, 0, buffer.Length);
             if (len <= 0)
             {
                 break;
             }
             output.Write(buffer, 0, len);
         }
     }
     brotliInput.Close();
     return(output.ToArray());
 }
Example #2
0
 /// <exception cref="System.IO.IOException"/>
 private byte[] DecompressWithDictionary(byte[] data, byte[] dictionary)
 {
     byte[] buffer = new byte[65536];
     System.IO.MemoryStream           input       = new System.IO.MemoryStream(data);
     System.IO.MemoryStream           output      = new System.IO.MemoryStream();
     Org.Brotli.Dec.BrotliInputStream brotliInput = new Org.Brotli.Dec.BrotliInputStream(input, Org.Brotli.Dec.BrotliInputStream.DefaultInternalBufferSize, dictionary);
     while (true)
     {
         int len = brotliInput.Read(buffer, 0, buffer.Length);
         if (len <= 0)
         {
             break;
         }
         output.Write(buffer, 0, len);
     }
     brotliInput.Close();
     return(output.ToArray());
 }
Example #3
0
        static void Decompress(Stream input, Stream output)
        {
            /// <exception cref="System.IO.IOException"/>

            byte[] buffer = new byte[65536];
            bool   byByte = false;

            Org.Brotli.Dec.BrotliInputStream brotliInput = new Org.Brotli.Dec.BrotliInputStream(input);
            if (byByte)
            {
                byte[] oneByte = new byte[1];
                while (true)
                {
                    int next = brotliInput.ReadByte();
                    if (next == -1)
                    {
                        break;
                    }
                    oneByte[0] = unchecked ((byte)next);
                    output.Write(oneByte, 0, 1);
                }
            }
            else
            {
                while (true)
                {
                    int len = brotliInput.Read(buffer, 0, buffer.Length);
                    if (len <= 0)
                    {
                        break;
                    }
                    output.Write(buffer, 0, len);
                }
            }
            brotliInput.Close();
        }