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 testParseLocalEntryAndGetCompressedDataOffset() 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.
      List<MinimalZipEntry> parsedEntries = new ArrayList<MinimalZipEntry>();
      for (int x = 0; x < UnitTestZipArchive.allEntriesInFileOrder.size(); x++) {
        parsedEntries.add(MinimalZipParser.parseCentralDirectoryEntry(in));
      }
  
      for (int x = 0; x < UnitTestZipArchive.allEntriesInFileOrder.size(); x++) {
        UnitTestZipEntry expectedEntry = UnitTestZipArchive.allEntriesInFileOrder.get(x);
        MinimalZipEntry parsedEntry = parsedEntries.get(x);
        in.reset();
        Assert.assertEquals(
            parsedEntry.getFileOffsetOfLocalEntry(),
            in.skip(parsedEntry.getFileOffsetOfLocalEntry()));
        long relativeDataOffset = MinimalZipParser.parseLocalEntryAndGetCompressedDataOffset(in);
        Assert.assertTrue(relativeDataOffset > 0);
        checkExpectedBytes(
            expectedEntry.getCompressedBinaryContent(),
            (int) (parsedEntry.getFileOffsetOfLocalEntry() + relativeDataOffset));
      }
    }
test_case.class_method_signature: MinimalZipParserTest.testParseLocalEntryAndGetCompressedDataOffset()
test_case.full_signature: @Test public void testParseLocalEntryAndGetCompressedDataOffset()
test_case.identifier: testParseLocalEntryAndGetCompressedDataOffset
test_case.invocations: mark locateStartOfEocd assertEquals skip parseEocd reset assertEquals getOffsetOfCentralDirectory skip getOffsetOfCentralDirectory size add parseCentralDirectoryEntry size get get reset assertEquals getFileOffsetOfLocalEntry skip getFileOffsetOfLocalEntry parseLocalEntryAndGetCompressedDataOffset assertTrue checkExpectedBytes getCompressedBinaryContent getFileOffsetOfLocalEntry
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testParseLocalEntryAndGetCompressedDataOffset()
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 long parseLocalEntryAndGetCompressedDataOffset(InputStream in) throws IOException {
      // *** 4 bytes encode the LOCAL_ENTRY_SIGNATURE, verify for sanity
      // 2 bytes encode the version-needed-to-extract, ignore
      // 2 bytes encode the general-purpose flags, ignore
      // 2 bytes encode the compression method, ignore (redundant with central directory)
      // 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, ignore (redundant with central directory)
      // 4 bytes encode the compressed size, ignore (redundant with central directory)
      // 4 bytes encode the uncompressed size, ignore (redundant with central directory)
      // *** 2 bytes encode the length of the file name, needed to skip the bytes later [READ THIS]
      // *** 2 bytes encode the length of the extras, needed to skip the bytes later [READ THIS]
      // The rest is the data, which is the main attraction here.
      if (((int) read32BitUnsigned(in)) != LOCAL_ENTRY_SIGNATURE) {
        throw new ZipException("Bad local entry header");
      }
      int junkLength = 2 + 2 + 2 + 2 + 2 + 4 + 4 + 4;
      skipOrDie(in, junkLength); // Skip everything up to the length of the file name
      final int fileNameLength = read16BitUnsigned(in);
      final int extrasLength = read16BitUnsigned(in);
  
      // The file name is already known and will match the central directory, so no need to read it.
      // The extra field length can be different here versus in the central directory and is used for
      // things like zipaligning APKs. This single value is the critical part as it dictates where the
      // actual DATA for the entry begins.
      return 4 + junkLength + 2 + 2 + fileNameLength + extrasLength;
    }
focal_method.class_method_signature: MinimalZipParser.parseLocalEntryAndGetCompressedDataOffset(InputStream in)
focal_method.full_signature: public static long parseLocalEntryAndGetCompressedDataOffset(InputStream in)
focal_method.identifier: parseLocalEntryAndGetCompressedDataOffset
focal_method.invocations: read32BitUnsigned skipOrDie read16BitUnsigned read16BitUnsigned
focal_method.modifiers: public static
focal_method.parameters: (InputStream in)
focal_method.return: long
focal_method.signature: long parseLocalEntryAndGetCompressedDataOffset(InputStream in)