示例#1
0
  public OutRawH3Impl(OutputStream os) {
    Objects.requireNonNull(os);
    _os = os;

    _tBuf = TempBuffer.create();
    _buffer = _tBuf.buffer();
    _length = _buffer.length;
  }
示例#2
0
  @Override
  public void close() {
    flush();

    TempBuffer tBuf = _tBuf;
    _tBuf = null;

    _buffer = null;

    if (tBuf != null) {
      tBuf.free();
    }
  }
示例#3
0
  private ZipEntry getZipEntryImpl(String path) throws IOException {
    if (path.startsWith("/")) {
      path = path.substring(1);
    }

    try (InputStream is = getBacking().openRead()) {
      try (ZipInputStream zIn = new ZipInputStream(is)) {
        ZipEntry entry;

        while ((entry = zIn.getNextEntry()) != null) {
          if (entry.getName().equals(path)) {
            ZipEntry entryResult = new ZipEntry(entry);

            if (entry.getSize() < 0 && !entry.isDirectory()) {
              long size = 0;
              TempBuffer tBuf = TempBuffer.create();
              byte[] buffer = tBuf.buffer();

              int sublen;
              while ((sublen = zIn.read(buffer, 0, buffer.length)) > 0) {
                size += sublen;
              }

              tBuf.free();

              entryResult.setSize(size);
            }

            return entryResult;
          }
        }
      }
    }

    return null;
  }