Crisis.Ionic.Zip.ZipEntry.FindExtraFieldSegment C# (CSharp) Method

FindExtraFieldSegment() static private method

Finds a particular segment in the given extra field. This is used when modifying a previously-generated extra field, in particular when removing the AES crypto segment in the extra field.
static private FindExtraFieldSegment ( byte extra, int offx, UInt16 targetHeaderId ) : int
extra byte
offx int
targetHeaderId System.UInt16
return int
        static internal int FindExtraFieldSegment(byte[] extra, int offx, UInt16 targetHeaderId)
        {
            int j = offx;
            while (j + 3 < extra.Length)
            {
                UInt16 headerId = (UInt16)(extra[j++] + extra[j++] * 256);
                if (headerId == targetHeaderId) return j-2;

                // else advance to next segment
                Int16 dataSize = (short)(extra[j++] + extra[j++] * 256);
                j+= dataSize;
            }

            return -1;
        }
ZipEntry