internal static void HandlePK00Prefix(Stream s) { // in some cases, the zip file begins with "PK00". This is a throwback and is rare, // but we handle it anyway. We do not change behavior based on it. uint datum = (uint)SharedUtilities.ReadInt(s); if (datum != ZipConstants.PackedToRemovableMedia) { s.Seek(-4, SeekOrigin.Current); // unread the block } }
private static void HandleUnexpectedDataDescriptor(ZipEntry entry) { Stream s = entry.ArchiveStream; // In some cases, the "data descriptor" is present, without a signature, even when // bit 3 of the BitField is NOT SET. This is the CRC, followed // by the compressed length and the uncompressed length (4 bytes for each // of those three elements). Need to check that here. // uint datum = (uint)SharedUtilities.ReadInt(s); if (datum == entry._Crc32) { int sz = SharedUtilities.ReadInt(s); if (sz == entry._CompressedSize) { sz = SharedUtilities.ReadInt(s); if (sz == entry._UncompressedSize) { // ignore everything and discard it. } else { s.Seek(-12, SeekOrigin.Current); // unread the three blocks } } else { s.Seek(-8, SeekOrigin.Current); // unread the two blocks } } else { s.Seek(-4, SeekOrigin.Current); // unread the block } }