예제 #1
0
  public boolean next() throws IOException {
    if (_entries <= _index) return false;

    _index++;

    ReadStream is = _is;

    if (is.readInt() != 0x504b0102) {
      throw new IOException("illegal zip format");
    }

    is.skip(2 + 2 + 2 + 2 + 2 + 2 + 4);

    int compressedSize = readInt(is);
    int uncompressedSize = readInt(is);

    int nameLen = is.read() + (is.read() << 8);
    int extraLen = is.read() + (is.read() << 8);
    int commentLen = is.read() + (is.read() << 8);

    is.skip(2 + 2 + 4);

    _localFileOffset = readInt(is);

    _nameLen = nameLen;
    if (_cbuf.length < nameLen) _cbuf = new char[nameLen];

    char[] cbuf = _cbuf;

    int k = is.readUTF8ByByteLength(cbuf, 0, nameLen);

    for (int i = k - 1; i >= 0; i--) {
      char ch = cbuf[i];

      // win32 canonicalize
      if (ch == '\\') cbuf[i] = '/';
    }

    _name = null; // new String(cbuf, 0, k);

    if (extraLen + commentLen > 0) is.skip(extraLen + commentLen);

    return true;
  }