コード例 #1
0
 public ZipOutputStream(Stream baseOutputStream)
     : base(baseOutputStream, new Deflater(Deflater.DEFAULT_COMPRESSION, true))
 {
     this.entries = new ArrayList();
     this.crc = new Crc32();
     this.curEntry = null;
     this.offset = 0;
     this.zipComment = new byte[0];
     this.defaultMethod = 8;
     this.shouldWriteBack = false;
     this.seekPos = -1;
 }
コード例 #2
0
 public GZipOutputStream(Stream baseOutputStream, int size)
     : base(baseOutputStream, new Deflater(Deflater.DEFAULT_COMPRESSION, true), size)
 {
     this.crc = new Crc32();
     int num = (int) (DateTime.Now.Ticks / 0x2710);
     byte[] buffer2 = new byte[10];
     buffer2[0] = (byte) (GZipConstants.GZIP_MAGIC >> 8);
     buffer2[1] = (byte) GZipConstants.GZIP_MAGIC;
     buffer2[2] = (byte) Deflater.DEFLATED;
     buffer2[4] = (byte) num;
     buffer2[5] = (byte) (num >> 8);
     buffer2[6] = (byte) (num >> 0x10);
     buffer2[7] = (byte) (num >> 0x18);
     buffer2[9] = 0xff;
     byte[] buffer = buffer2;
     baseOutputStream.Write(buffer, 0, buffer.Length);
 }
コード例 #3
0
 private void ReadHeader()
 {
     Crc32 crc = new Crc32();
     int bval = base.baseInputStream.ReadByte();
     if (bval < 0)
     {
         this.eos = true;
     }
     else
     {
         crc.Update(bval);
         if (bval != (GZipConstants.GZIP_MAGIC >> 8))
         {
             throw new IOException("Error baseInputStream GZIP header, first byte doesn't match");
         }
         bval = base.baseInputStream.ReadByte();
         if (bval != (GZipConstants.GZIP_MAGIC & 0xff))
         {
             throw new IOException("Error baseInputStream GZIP header,  second byte doesn't match");
         }
         crc.Update(bval);
         int num2 = base.baseInputStream.ReadByte();
         if (num2 != 8)
         {
             throw new IOException("Error baseInputStream GZIP header, data not baseInputStream deflate format");
         }
         crc.Update(num2);
         int num3 = base.baseInputStream.ReadByte();
         if (num3 < 0)
         {
             throw new Exception("Early EOF baseInputStream GZIP header");
         }
         crc.Update(num3);
         if ((num3 & 0xd0) != 0)
         {
             throw new IOException("Reserved flag bits baseInputStream GZIP header != 0");
         }
         for (int i = 0; i < 6; i++)
         {
             int num5 = base.baseInputStream.ReadByte();
             if (num5 < 0)
             {
                 throw new Exception("Early EOF baseInputStream GZIP header");
             }
             crc.Update(num5);
         }
         if ((num3 & 4) != 0)
         {
             for (int j = 0; j < 2; j++)
             {
                 int num7 = base.baseInputStream.ReadByte();
                 if (num7 < 0)
                 {
                     throw new Exception("Early EOF baseInputStream GZIP header");
                 }
                 crc.Update(num7);
             }
             if ((base.baseInputStream.ReadByte() < 0) || (base.baseInputStream.ReadByte() < 0))
             {
                 throw new Exception("Early EOF baseInputStream GZIP header");
             }
             int num8 = base.baseInputStream.ReadByte();
             int num9 = base.baseInputStream.ReadByte();
             if ((num8 < 0) || (num9 < 0))
             {
                 throw new Exception("Early EOF baseInputStream GZIP header");
             }
             crc.Update(num8);
             crc.Update(num9);
             int num10 = (num8 << 8) | num9;
             for (int k = 0; k < num10; k++)
             {
                 int num12 = base.baseInputStream.ReadByte();
                 if (num12 < 0)
                 {
                     throw new Exception("Early EOF baseInputStream GZIP header");
                 }
                 crc.Update(num12);
             }
         }
         if ((num3 & 8) != 0)
         {
             int num13;
             while ((num13 = base.baseInputStream.ReadByte()) > 0)
             {
                 crc.Update(num13);
             }
             if (num13 < 0)
             {
                 throw new Exception("Early EOF baseInputStream GZIP file name");
             }
             crc.Update(num13);
         }
         if ((num3 & 0x10) != 0)
         {
             int num14;
             while ((num14 = base.baseInputStream.ReadByte()) > 0)
             {
                 crc.Update(num14);
             }
             if (num14 < 0)
             {
                 throw new Exception("Early EOF baseInputStream GZIP comment");
             }
             crc.Update(num14);
         }
         if ((num3 & 2) != 0)
         {
             int num16 = base.baseInputStream.ReadByte();
             if (num16 < 0)
             {
                 throw new Exception("Early EOF baseInputStream GZIP header");
             }
             int num15 = base.baseInputStream.ReadByte();
             if (num15 < 0)
             {
                 throw new Exception("Early EOF baseInputStream GZIP header");
             }
             num16 = (num16 << 8) | num15;
             if (num16 != (((int) crc.Value) & 0xffff))
             {
                 throw new IOException("Header CRC value mismatch");
             }
         }
         this.readGZIPHeader = true;
     }
 }
コード例 #4
0
 public GZipInputStream(Stream baseInputStream, int size)
     : base(baseInputStream, new Inflater(true), size)
 {
     this.crc = new Crc32();
 }
コード例 #5
0
 public override void Close()
 {
     base.Close();
     this.crc = null;
     this.entry = null;
 }
コード例 #6
0
 public ZipInputStream(Stream baseInputStream)
     : base(baseInputStream, new Inflater(true))
 {
     this.crc = new Crc32();
     this.entry = null;
 }