@Test public void testLocateStartOfEocd_WithArray() { int eocdOffset = MinimalZipParser.locateStartOfEocd(unitTestZipArchive); checkExpectedBytes(new byte[] {0x50, 0x4b, 0x05, 0x06}, eocdOffset); }
public static long locateStartOfEocd(RandomAccessFileInputStream in, int searchBufferLength) throws IOException { final int maxBufferSize = (int) Math.min(searchBufferLength, in.length()); final byte[] buffer = new byte[maxBufferSize]; final long rangeStart = in.length() - buffer.length; in.setRange(rangeStart, buffer.length); readOrDie(in, buffer, 0, buffer.length); int offset = locateStartOfEocd(buffer); if (offset == -1) { return -1; } return rangeStart + offset; }
MinimalZipParser { public static long locateStartOfEocd(RandomAccessFileInputStream in, int searchBufferLength) throws IOException { final int maxBufferSize = (int) Math.min(searchBufferLength, in.length()); final byte[] buffer = new byte[maxBufferSize]; final long rangeStart = in.length() - buffer.length; in.setRange(rangeStart, buffer.length); readOrDie(in, buffer, 0, buffer.length); int offset = locateStartOfEocd(buffer); if (offset == -1) { return -1; } return rangeStart + offset; } }
MinimalZipParser { public static long locateStartOfEocd(RandomAccessFileInputStream in, int searchBufferLength) throws IOException { final int maxBufferSize = (int) Math.min(searchBufferLength, in.length()); final byte[] buffer = new byte[maxBufferSize]; final long rangeStart = in.length() - buffer.length; in.setRange(rangeStart, buffer.length); readOrDie(in, buffer, 0, buffer.length); int offset = locateStartOfEocd(buffer); if (offset == -1) { return -1; } return rangeStart + offset; }  }
MinimalZipParser { public static long locateStartOfEocd(RandomAccessFileInputStream in, int searchBufferLength) throws IOException { final int maxBufferSize = (int) Math.min(searchBufferLength, in.length()); final byte[] buffer = new byte[maxBufferSize]; final long rangeStart = in.length() - buffer.length; in.setRange(rangeStart, buffer.length); readOrDie(in, buffer, 0, buffer.length); int offset = locateStartOfEocd(buffer); if (offset == -1) { return -1; } return rangeStart + offset; }  static MinimalZipEntry parseCentralDirectoryEntry(InputStream in); static long parseLocalEntryAndGetCompressedDataOffset(InputStream in); static long locateStartOfEocd(RandomAccessFileInputStream in, int searchBufferLength); static int locateStartOfEocd(byte[] buffer); static MinimalCentralDirectoryMetadata parseEocd(InputStream in); }
MinimalZipParser { public static long locateStartOfEocd(RandomAccessFileInputStream in, int searchBufferLength) throws IOException { final int maxBufferSize = (int) Math.min(searchBufferLength, in.length()); final byte[] buffer = new byte[maxBufferSize]; final long rangeStart = in.length() - buffer.length; in.setRange(rangeStart, buffer.length); readOrDie(in, buffer, 0, buffer.length); int offset = locateStartOfEocd(buffer); if (offset == -1) { return -1; } return rangeStart + offset; }  static MinimalZipEntry parseCentralDirectoryEntry(InputStream in); static long parseLocalEntryAndGetCompressedDataOffset(InputStream in); static long locateStartOfEocd(RandomAccessFileInputStream in, int searchBufferLength); static int locateStartOfEocd(byte[] buffer); static MinimalCentralDirectoryMetadata parseEocd(InputStream in); static final int EOCD_SIGNATURE; static final int CENTRAL_DIRECTORY_ENTRY_SIGNATURE; static final int LOCAL_ENTRY_SIGNATURE; }