test_class.declarator: unitTestZipArchive
test_class.modifier: private
test_class.original_string: private byte[] unitTestZipArchive;
test_class.type: byte[]
test_class.var_name: unitTestZipArchive
test_class.file: feya/libraries/archive_diff/diff.generator/src/test/java/com/google/archivepatcher/generator/MinimalZipParserTest.java
test_class.identifier: MinimalZipParserTest
test_case.body: @Test
    public void testParseCentralDirectoryEntry() throws Exception {
      ByteArrayInputStream in = new ByteArrayInputStream(unitTestZipArchive);
      in.mark(unitTestZipArchive.length);
      int eocdOffset = MinimalZipParser.locateStartOfEocd(unitTestZipArchive);
      Assert.assertEquals(eocdOffset, in.skip(eocdOffset));
      MinimalCentralDirectoryMetadata metadata = MinimalZipParser.parseEocd(in);
      in.reset();
      Assert.assertEquals(
          metadata.getOffsetOfCentralDirectory(), in.skip(metadata.getOffsetOfCentralDirectory()));
  
      // Read each entry and verify all fields *except* the value returned by
      // MinimalZipEntry.getFileOffsetOfCompressedData(), as that has yet to be computed.
      for (UnitTestZipEntry expectedEntry : UnitTestZipArchive.allEntriesInFileOrder) {
        MinimalZipEntry parsed = MinimalZipParser.parseCentralDirectoryEntry(in);
        Assert.assertEquals(expectedEntry.path, parsed.getFileName());
  
        // Verify that the local signature header is at the calculated position
        byte[] expectedSignatureBlock = new byte[] {0x50, 0x4b, 0x03, 0x04};
        for (int index = 0; index < 4; index++) {
          byte actualByte = unitTestZipArchive[((int) parsed.getFileOffsetOfLocalEntry()) + index];
          Assert.assertEquals(expectedSignatureBlock[index], actualByte);
        }
  
        if (expectedEntry.level > 0) {
          Assert.assertEquals(8 /* deflate */, parsed.getCompressionMethod());
        } else {
          Assert.assertEquals(0 /* store */, parsed.getCompressionMethod());
        }
        byte[] uncompressedContent = expectedEntry.getUncompressedBinaryContent();
        Assert.assertEquals(uncompressedContent.length, parsed.getUncompressedSize());
        CRC32 crc32 = new CRC32();
        crc32.update(uncompressedContent);
        Assert.assertEquals(crc32.getValue(), parsed.getCrc32OfUncompressedData());
        byte[] compressedContent = expectedEntry.getCompressedBinaryContent();
        Assert.assertEquals(compressedContent.length, parsed.getCompressedSize());
      }
    }
test_case.class_method_signature: MinimalZipParserTest.testParseCentralDirectoryEntry()
test_case.full_signature: @Test public void testParseCentralDirectoryEntry()
test_case.identifier: testParseCentralDirectoryEntry
test_case.invocations: mark locateStartOfEocd assertEquals skip parseEocd reset assertEquals getOffsetOfCentralDirectory skip getOffsetOfCentralDirectory parseCentralDirectoryEntry assertEquals getFileName getFileOffsetOfLocalEntry assertEquals assertEquals getCompressionMethod assertEquals getCompressionMethod getUncompressedBinaryContent assertEquals getUncompressedSize update assertEquals getValue getCrc32OfUncompressedData getCompressedBinaryContent assertEquals getCompressedSize
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testParseCentralDirectoryEntry()
focal_class.declarator: EOCD_SIGNATURE = 0x06054b50
focal_class.modifier: public static final
focal_class.original_string: public static final int EOCD_SIGNATURE = 0x06054b50;
focal_class.type: int
focal_class.var_name: EOCD_SIGNATURE
focal_class.declarator: CENTRAL_DIRECTORY_ENTRY_SIGNATURE = 0x02014b50
focal_class.modifier: public static final
focal_class.original_string: public static final int CENTRAL_DIRECTORY_ENTRY_SIGNATURE = 0x02014b50;
focal_class.type: int
focal_class.var_name: CENTRAL_DIRECTORY_ENTRY_SIGNATURE
focal_class.declarator: LOCAL_ENTRY_SIGNATURE = 0x04034b50
focal_class.modifier: public static final
focal_class.original_string: public static final int LOCAL_ENTRY_SIGNATURE = 0x04034b50;
focal_class.type: int
focal_class.var_name: LOCAL_ENTRY_SIGNATURE
focal_class.file: feya/libraries/archive_diff/diff.generator/src/main/java/com/google/archivepatcher/generator/MinimalZipParser.java
focal_class.identifier: MinimalZipParser
focal_class.class_method_signature: MinimalZipParser.readByteOrDie(InputStream in)
focal_class.full_signature: private static int readByteOrDie(InputStream in)
focal_class.identifier: readByteOrDie
focal_class.modifiers: private static
focal_class.parameters: (InputStream in)
focal_class.return: int
focal_class.signature: int readByteOrDie(InputStream in)
focal_class.class_method_signature: MinimalZipParser.skipOrDie(InputStream in, long numBytes)
focal_class.full_signature: private static void skipOrDie(InputStream in, long numBytes)
focal_class.identifier: skipOrDie
focal_class.modifiers: private static
focal_class.parameters: (InputStream in, long numBytes)
focal_class.return: void
focal_class.signature: void skipOrDie(InputStream in, long numBytes)
focal_class.class_method_signature: MinimalZipParser.read16BitUnsigned(InputStream in)
focal_class.full_signature: private static int read16BitUnsigned(InputStream in)
focal_class.identifier: read16BitUnsigned
focal_class.modifiers: private static
focal_class.parameters: (InputStream in)
focal_class.return: int
focal_class.signature: int read16BitUnsigned(InputStream in)
focal_class.class_method_signature: MinimalZipParser.read32BitUnsigned(InputStream in)
focal_class.full_signature: private static long read32BitUnsigned(InputStream in)
focal_class.identifier: read32BitUnsigned
focal_class.modifiers: private static
focal_class.parameters: (InputStream in)
focal_class.return: long
focal_class.signature: long read32BitUnsigned(InputStream in)
focal_class.class_method_signature: MinimalZipParser.readOrDie(InputStream in, byte[] buffer, int offset, int length)
focal_class.full_signature: private static void readOrDie(InputStream in, byte[] buffer, int offset, int length)
focal_class.identifier: readOrDie
focal_class.modifiers: private static
focal_class.parameters: (InputStream in, byte[] buffer, int offset, int length)
focal_class.return: void
focal_class.signature: void readOrDie(InputStream in, byte[] buffer, int offset, int length)
focal_class.class_method_signature: MinimalZipParser.parseCentralDirectoryEntry(InputStream in)
focal_class.full_signature: public static MinimalZipEntry parseCentralDirectoryEntry(InputStream in)
focal_class.identifier: parseCentralDirectoryEntry
focal_class.modifiers: public static
focal_class.parameters: (InputStream in)
focal_class.return: MinimalZipEntry
focal_class.signature: MinimalZipEntry parseCentralDirectoryEntry(InputStream in)
focal_class.class_method_signature: MinimalZipParser.parseLocalEntryAndGetCompressedDataOffset(InputStream in)
focal_class.full_signature: public static long parseLocalEntryAndGetCompressedDataOffset(InputStream in)
focal_class.identifier: parseLocalEntryAndGetCompressedDataOffset
focal_class.modifiers: public static
focal_class.parameters: (InputStream in)
focal_class.return: long
focal_class.signature: long parseLocalEntryAndGetCompressedDataOffset(InputStream in)
focal_class.class_method_signature: MinimalZipParser.locateStartOfEocd(RandomAccessFileInputStream in, int searchBufferLength)
focal_class.full_signature: public static long locateStartOfEocd(RandomAccessFileInputStream in, int searchBufferLength)
focal_class.identifier: locateStartOfEocd
focal_class.modifiers: public static
focal_class.parameters: (RandomAccessFileInputStream in, int searchBufferLength)
focal_class.return: long
focal_class.signature: long locateStartOfEocd(RandomAccessFileInputStream in, int searchBufferLength)
focal_class.class_method_signature: MinimalZipParser.locateStartOfEocd(byte[] buffer)
focal_class.full_signature: public static int locateStartOfEocd(byte[] buffer)
focal_class.identifier: locateStartOfEocd
focal_class.modifiers: public static
focal_class.parameters: (byte[] buffer)
focal_class.return: int
focal_class.signature: int locateStartOfEocd(byte[] buffer)
focal_class.class_method_signature: MinimalZipParser.parseEocd(InputStream in)
focal_class.full_signature: public static MinimalCentralDirectoryMetadata parseEocd(InputStream in)
focal_class.identifier: parseEocd
focal_class.modifiers: public static
focal_class.parameters: (InputStream in)
focal_class.return: MinimalCentralDirectoryMetadata
focal_class.signature: MinimalCentralDirectoryMetadata parseEocd(InputStream in)
focal_method.body: public static MinimalZipEntry parseCentralDirectoryEntry(InputStream in) throws IOException {
      // *** 4 bytes encode the CENTRAL_DIRECTORY_ENTRY_SIGNATURE, verify for sanity
      // 2 bytes encode the version-made-by, ignore
      // 2 bytes encode the version-needed-to-extract, ignore
      // *** 2 bytes encode the general-purpose flags, read for language encoding. [READ THIS]
      // *** 2 bytes encode the compression method, [READ THIS]
      // 2 bytes encode the MSDOS last modified file time, ignore
      // 2 bytes encode the MSDOS last modified file date, ignore
      // *** 4 bytes encode the CRC32 of the uncompressed data [READ THIS]
      // *** 4 bytes encode the compressed size [READ THIS]
      // *** 4 bytes encode the uncompressed size [READ THIS]
      // *** 2 bytes encode the length of the file name [READ THIS]
      // *** 2 bytes encode the length of the extras, needed to skip the bytes later [READ THIS]
      // *** 2 bytes encode the length of the comment, needed to skip the bytes later [READ THIS]
      // 2 bytes encode the disk number, ignore
      // 2 bytes encode the internal file attributes, ignore
      // 4 bytes encode the external file attributes, ignore
      // *** 4 bytes encode the offset of the local section entry, where the data is [READ THIS]
      // n bytes encode the file name
      // n bytes encode the extras
      // n bytes encode the comment
      if (((int) read32BitUnsigned(in)) != CENTRAL_DIRECTORY_ENTRY_SIGNATURE) {
        throw new ZipException("Bad central directory header");
      }
      skipOrDie(in, 2 + 2); // Skip version stuff
      int generalPurposeFlags = read16BitUnsigned(in);
      int compressionMethod = read16BitUnsigned(in);
      skipOrDie(in, 2 + 2); // Skip MSDOS junk
      long crc32OfUncompressedData = read32BitUnsigned(in);
      long compressedSize = read32BitUnsigned(in);
      long uncompressedSize = read32BitUnsigned(in);
      int fileNameLength = read16BitUnsigned(in);
      int extrasLength = read16BitUnsigned(in);
      int commentLength = read16BitUnsigned(in);
      skipOrDie(in, 2 + 2 + 4); // Skip the disk number and file attributes
      long fileOffsetOfLocalEntry = read32BitUnsigned(in);
      byte[] fileNameBuffer = new byte[fileNameLength];
      readOrDie(in, fileNameBuffer, 0, fileNameBuffer.length);
      skipOrDie(in, extrasLength + commentLength);
      // General purpose flag bit 11 is an important hint for the character set used for file names.
      boolean generalPurposeFlagBit11 = (generalPurposeFlags & (0x1 << 10)) != 0;
      return new MinimalZipEntry(
          compressionMethod,
          crc32OfUncompressedData,
          compressedSize,
          uncompressedSize,
          fileNameBuffer,
          generalPurposeFlagBit11,
          fileOffsetOfLocalEntry);
    }
focal_method.class_method_signature: MinimalZipParser.parseCentralDirectoryEntry(InputStream in)
focal_method.full_signature: public static MinimalZipEntry parseCentralDirectoryEntry(InputStream in)
focal_method.identifier: parseCentralDirectoryEntry
focal_method.invocations: read32BitUnsigned skipOrDie read16BitUnsigned read16BitUnsigned skipOrDie read32BitUnsigned read32BitUnsigned read32BitUnsigned read16BitUnsigned read16BitUnsigned read16BitUnsigned skipOrDie read32BitUnsigned readOrDie skipOrDie
focal_method.modifiers: public static
focal_method.parameters: (InputStream in)
focal_method.return: MinimalZipEntry
focal_method.signature: MinimalZipEntry parseCentralDirectoryEntry(InputStream in)