Ejemplo n.º 1
0
  public boolean open() throws IOException {
    if (!_isValid) return false;

    _is = _path.openRead();
    _is.skip(_offset);
    _index = 0;

    return true;
  }
Ejemplo n.º 2
0
  /**
   * Creates a new Jar.
   *
   * @param path canonical path
   */
  public ZipScanner(Path path) {
    try {
      _path = path;

      int length = (int) path.getLength();

      ReadStream is = path.openRead();

      try {
        // PACK200 is a standard comment, so try skipping it first
        is.skip(length - 22 - 7);

        if (is.read() != 0x50) {
          is.skip(6);

          if (is.read() != 0x50) return;
        }

        if (is.read() == 0x4b && is.read() == 0x05 && is.read() == 0x06) {
          _isValid = true;
        }

        if (_isValid) {
          is.skip(6);

          _entries = is.read() + (is.read() << 8);
          is.skip(4);

          _offset = readInt(is);
        }
      } finally {
        is.close();
      }
    } catch (Exception e) {
      log().log(Level.FINER, e.toString(), e);
    }
  }