New test.
[mono.git] / mcs / class / ByteFX.Data / Common / Inflater.cs
1 using System;\r
2 using System.IO;\r
3 \r
4 namespace ByteFX.Data.Common\r
5 {\r
6         /// <summary>\r
7         /// Summary description for Inflater.\r
8         /// </summary>\r
9         public class Inflater\r
10         {\r
11                 private BitStream _input;\r
12 \r
13                 public Inflater()\r
14                 {\r
15                 }\r
16 \r
17                 public void SetInput(byte[] input, int offset, int len)\r
18                 {\r
19                         _input = new BitStream(input, offset, len);\r
20                 }\r
21 \r
22                 public void Inflate(byte[] output, int offset, int size)\r
23                 {\r
24                         byte cmf = (byte)_input.GetBits(8);\r
25                         byte flag = (byte)_input.GetBits(8);\r
26 \r
27                         if ((cmf & 0x0f) != 8)\r
28                                 throw new Exception("Only deflate format data is supported");\r
29 \r
30                         if (((cmf*256+flag) % 31) != 0)\r
31                                 throw new Exception("Data is not in proper deflate format");\r
32 \r
33 \r
34 \r
35                 }\r
36         }\r
37 }\r