Пример #1
0
        public static void ProcessFile(IEnumerable <string> fileNameList, Stream zipFile, int compressionAmount,
                                       string password, Stream[] fileStreamList)
        {
            if (compressionAmount >= 0 && compressionAmount <= 9)
            {
                var @class = new Class192();
                var stream = new Stream23(zipFile);
                stream.method_6(compressionAmount);
                if (password != null)
                {
                    stream.method_2(password);
                }
                var num = 0;
                using (var enumerator = fileNameList.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        var current = enumerator.Current;
                        var class2  = new Class193(current);
                        class2.method_19(DateTime.Now);
                        var    stream2 = fileStreamList[num++];
                        byte[] array;
                        if (stream2 is MemoryStream)
                        {
                            array = (stream2 as MemoryStream).ToArray();
                        }
                        else
                        {
                            array = new byte[stream2.Length];
                            var num2 = stream2.Read(array, 0, array.Length);
                            if (num2 < array.Length)
                            {
                                Array.Resize(ref array, num2);
                            }
                        }
                        class2.method_22(array.Length);
                        @class.vmethod_1();
                        @class.vmethod_2(array);
                        class2.method_26(@class.vmethod_0());
                        stream.method_10(class2);
                        stream.Write(array, 0, array.Length);
                    }
                    goto IL_10D;
                }
                goto IL_102;
IL_10D:
                stream.vmethod_0();
                stream.Close();
                return;
            }
IL_102:
            throw new ArgumentException("Invalid compression rate.");
        }
Пример #2
0
        public void method_11()
        {
            if (_class1930 == null)
            {
                throw new InvalidOperationException("No open entry");
            }
            if (_enum310 == Enum31.Const1)
            {
                base.vmethod_0();
            }
            var num = (_enum310 == Enum31.Const1) ? Class1940.method_1() : _long0;

            if (_class1930.method_21() < 0L)
            {
                _class1930.method_22(_long0);
            }
            else if (_class1930.method_21() != _long0)
            {
                throw new ZipException(string.Concat("size was ", _long0, ", but I expected ", _class1930.method_21()));
            }
            if (_class1930.method_23() < 0L)
            {
                _class1930.method_24(num);
            }
            else if (_class1930.method_23() != num)
            {
                throw new ZipException(string.Concat("compressed size was ", num, ", but I expected ",
                                                     _class1930.method_23()));
            }
            if (_class1930.method_25() < 0L)
            {
                _class1930.method_26(_class1920.vmethod_0());
            }
            else if (_class1930.method_25() != _class1920.vmethod_0())
            {
                throw new ZipException(string.Concat("crc was ", _class1920.vmethod_0(), ", but I expected ",
                                                     _class1930.method_25()));
            }
            _long1 += num;
            if (_class1930.method_0())
            {
                var expr_1E6 = _class1930;
                expr_1E6.method_24(expr_1E6.method_23() + 12L);
            }
            if (_bool2)
            {
                _bool2 = false;
                var position = Stream0.Position;
                Stream0.Seek(_long2, SeekOrigin.Begin);
                method_8((int)_class1930.method_25());
                if (_class1930.method_15())
                {
                    if (_long3 == -1L)
                    {
                        throw new ZipException("Entry requires zip64 but this has been turned off");
                    }
                    Stream0.Seek(_long3, SeekOrigin.Begin);
                    method_9(_class1930.method_21());
                    method_9(_class1930.method_23());
                }
                else
                {
                    method_8((int)_class1930.method_23());
                    method_8((int)_class1930.method_21());
                }
                Stream0.Seek(position, SeekOrigin.Begin);
            }
            if ((_class1930.method_4() & 8) != 0)
            {
                method_8(134695760);
                method_8((int)_class1930.method_25());
                if (_class1930.method_15())
                {
                    method_9(_class1930.method_23());
                    method_9(_class1930.method_21());
                    _long1 += 24L;
                }
                else
                {
                    method_8((int)_class1930.method_23());
                    method_8((int)_class1930.method_21());
                    _long1 += 16L;
                }
            }
            _arrayList0.Add(_class1930);
            _class1930 = null;
        }