Ejemplo n.º 1
0
        static void compress2(ref byte[] dest, byte[] src, int level, bool noHeader)
        {
            ZStream stream = new ZStream();

            stream.next_in = src;
            stream.avail_in = src.Length;

            stream.next_out = dest;
            stream.avail_out = dest.Length;

            if (noHeader == false)
            {
                stream.deflateInit(level);
            }
            else
            {
                stream.deflateInit(level, -15);
            }

            stream.deflate(zlibConst.Z_FINISH);

            Array.Resize<byte>(ref dest, (int)stream.total_out);
        }
Ejemplo n.º 2
0
		public GZipPacker()
		{
			fifo = new Fifo();

			zs = new ZStream();
			zs.deflateInit(-1, -15);

			this.currentSize = 0;
			this.crc32 = 0xffffffff;
			this.finished = false;

			GZipHeader h = new GZipHeader();
			h.ID1 = 0x1f;
			h.ID2 = 0x8b;
			h.FLG = 0;
			h.MTIME = Util.DateTimeToUnixTime(DateTime.Now.ToUniversalTime());
			h.XFL = 0;
			h.OS = 3;
			h.CM = 8;

			fifo.Write(Util.StructToByte(h));
		}