ICSharpCode.SharpZipLib.Zip.ZipExtraData.Find C# (CSharp) Method

Find() public method

Find an extra data value
public Find ( int headerID ) : bool
headerID int The identifier for the value to find.
return bool
        public bool Find(int headerID) {
            _readValueStart=_data.Length;
            _readValueLength=0;
            _index=0;

            int localLength=_readValueStart;
            int localTag=headerID-1;

            // Trailing bytes that cant make up an entry (as there arent enough
            // bytes for a tag and length) are ignored!
            while ((localTag!=headerID)&&(_index<_data.Length-3)) {
                localTag=ReadShortInternal();
                localLength=ReadShortInternal();
                if (localTag!=headerID) {
                    _index+=localLength;
                }
            }

            bool result=(localTag==headerID)&&((_index+localLength)<=_data.Length);

            if (result) {
                _readValueStart=_index;
                _readValueLength=localLength;
            }

            return result;
        }

Usage Example

Beispiel #1
0
        internal void ProcessExtraData(bool localHeader)
        {
            ZipExtraData zipExtraData = new ZipExtraData(this.extra);

            if (zipExtraData.Find(1))
            {
                this.forceZip64_ = true;
                if (zipExtraData.ValueLength < 4)
                {
                    throw new ZipException("Extra data extended Zip64 information length is invalid");
                }
                if (this.size == (ulong)-1)
                {
                    this.size = (ulong)zipExtraData.ReadLong();
                }
                if (this.compressedSize == (ulong)-1)
                {
                    this.compressedSize = (ulong)zipExtraData.ReadLong();
                }
                if (!localHeader && this.offset == (long)((ulong)-1))
                {
                    this.offset = zipExtraData.ReadLong();
                }
            }
            else if ((this.versionToExtract & 255) >= 45 && (this.size == (ulong)-1 || this.compressedSize == (ulong)-1))
            {
                throw new ZipException("Zip64 Extended information required but is missing.");
            }
            this.DateTime = this.GetDateTime(zipExtraData);
            if (this.method == CompressionMethod.WinZipAES)
            {
                this.ProcessAESExtraData(zipExtraData);
            }
        }
All Usage Examples Of ICSharpCode.SharpZipLib.Zip.ZipExtraData::Find