Exemple #1
0
        protected void LoadExtra(byte[] extra)
        {
            for (int i = 0; i < extra.Length - 4;)
            {
                ExtraDataType type = (ExtraDataType)BinaryPrimitives.ReadUInt16LittleEndian(extra.AsSpan(i));
                if (!Enum.IsDefined(typeof(ExtraDataType), type))
                {
                    type = ExtraDataType.NotImplementedExtraData;
                }

                ushort length = BinaryPrimitives.ReadUInt16LittleEndian(extra.AsSpan(i + 2));

                // 7zip has this same kind of check to ignore extras blocks that don't conform to the standard 2-byte ID, 2-byte length, N-byte value.
                // CPP/7Zip/Zip/ZipIn.cpp: CInArchive::ReadExtra
                if (length > extra.Length)
                {
                    // bad extras block
                    return;
                }

                byte[] data = new byte[length];
                Buffer.BlockCopy(extra, i + 4, data, 0, length);
                Extra.Add(LocalEntryHeaderExtraFactory.Create(type, length, data));

                i += length + 4;
            }
        }
        protected void LoadExtra(byte[] extra)
        {
            ushort num2;

            for (int i = 0; i < (extra.Length - 4); i += num2 + 4)
            {
                ExtraDataType notImplementedExtraData = (ExtraDataType)BitConverter.ToUInt16(extra, i);
                if (!Enum.IsDefined(typeof(ExtraDataType), notImplementedExtraData))
                {
                    notImplementedExtraData = ExtraDataType.NotImplementedExtraData;
                }
                num2 = BitConverter.ToUInt16(extra, i + 2);
                byte[] dst = new byte[num2];
                Buffer.BlockCopy(extra, i + 4, dst, 0, num2);
                this.Extra.Add(LocalEntryHeaderExtraFactory.Create(notImplementedExtraData, num2, dst));
            }
        }
        protected void LoadExtra(byte[] extra)
        {
            for (int i = 0; i < extra.Length - 4;)
            {
                ExtraDataType type = (ExtraDataType)DataConverter.LittleEndian.GetUInt16(extra, i);
                if (!Enum.IsDefined(typeof(ExtraDataType), type))
                {
                    type = ExtraDataType.NotImplementedExtraData;
                }

                ushort length = DataConverter.LittleEndian.GetUInt16(extra, i + 2);
                byte[] data   = new byte[length];
                Buffer.BlockCopy(extra, i + 4, data, 0, length);
                Extra.Add(LocalEntryHeaderExtraFactory.Create(type, length, data));

                i += length + 4;
            }
        }