class 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;
  }

}