org.apache.tools.zip.ZipEntry.getSize()方法的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(7.1k)|赞(0)|评价(0)|浏览(141)

本文整理了Java中org.apache.tools.zip.ZipEntry.getSize()方法的一些代码示例,展示了ZipEntry.getSize()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipEntry.getSize()方法的具体详情如下:
包路径:org.apache.tools.zip.ZipEntry
类名称:ZipEntry
方法名:getSize

ZipEntry.getSize介绍

[英]Gets the uncompressed size of the entry data.
[中]获取条目数据的未压缩大小。

代码示例

代码示例来源:origin: org.apache.ant/ant

/**
 * Whether to add a Zip64 extended information extra field to the
 * local file header.
 *
 * <p>Returns true if</p>
 *
 * <ul>
 * <li>mode is Always</li>
 * <li>or we already know it is going to be needed</li>
 * <li>or the size is unknown and we can ensure it won't hurt
 * other implementations if we add it (i.e. we can erase its
 * usage</li>
 * </ul>
 *
 * @param entry ZipEntry
 * @param mode Zip64Mode
 */
private boolean shouldAddZip64Extra(ZipEntry entry, Zip64Mode mode) {
  return mode == Zip64Mode.Always
    || entry.getSize() >= ZIP64_MAGIC
    || entry.getCompressedSize() >= ZIP64_MAGIC
    || (entry.getSize() == -1
      && raf != null && mode != Zip64Mode.Never);
}

代码示例来源:origin: org.apache.ant/ant

private boolean isTooLageForZip32(ZipEntry zipArchiveEntry) {
  return zipArchiveEntry.getSize() >= ZIP64_MAGIC
    || zipArchiveEntry.getCompressedSize() >= ZIP64_MAGIC;
}

代码示例来源:origin: org.apache.ant/ant

/**
 * If the mode is AsNeeded and the entry is a compressed entry of
 * unknown size that gets written to a non-seekable stream the
 * change the default to Never.
 *
 * @param ze ZipEntry
 * @return Zip64Mode
 */
private Zip64Mode getEffectiveZip64Mode(ZipEntry ze) {
  if (zip64Mode != Zip64Mode.AsNeeded
    || raf != null
    || ze.getMethod() != DEFLATED
    || ze.getSize() != -1) {
    return zip64Mode;
  }
  return Zip64Mode.Never;
}

代码示例来源:origin: org.apache.ant/ant

/**
 * Throws an exception if the size is unknown for a stored entry
 * that is written to a non-seekable output or the entry is too
 * big to be written without Zip64 extra but the mode has been set
 * to Never.
 *
 * @param effectiveMode Zip64Mode
 */
private void validateSizeInformation(Zip64Mode effectiveMode)
  throws ZipException {
  // Size/CRC not required if RandomAccessFile is used
  if (entry.entry.getMethod() == STORED && raf == null) {
    if (entry.entry.getSize() == -1) {
      throw new ZipException("uncompressed size is required for"
                  + " STORED method when not writing to a"
                  + " file");
    }
    if (entry.entry.getCrc() == -1) {
      throw new ZipException("crc checksum is required for STORED"
                  + " method when not writing to a file");
    }
    entry.entry.setCompressedSize(entry.entry.getSize());
  }
  if ((entry.entry.getSize() >= ZIP64_MAGIC
     || entry.entry.getCompressedSize() >= ZIP64_MAGIC)
    && effectiveMode == Zip64Mode.Never) {
    throw new Zip64RequiredException(Zip64RequiredException
                     .getEntryTooBigMessage(entry.entry));
  }
}

代码示例来源:origin: org.apache.ant/ant

private byte[] createCentralFileHeader(ZipEntry ze) throws IOException {
  final long lfhOffset = offsets.get(ze);
  final boolean needsZip64Extra = hasZip64Extra(ze)
      || ze.getCompressedSize() >= ZIP64_MAGIC
      || ze.getSize() >= ZIP64_MAGIC
      || lfhOffset >= ZIP64_MAGIC;
  if (needsZip64Extra && zip64Mode == Zip64Mode.Never) {
    // must be the offset that is too big, otherwise an
    // exception would have been throw in putArchiveEntry or
    // closeArchiveEntry
    throw new Zip64RequiredException(Zip64RequiredException
        .ARCHIVE_TOO_BIG_MESSAGE);
  }
  handleZip64Extra(ze, lfhOffset, needsZip64Extra);
  return createCentralFileHeader(ze, getName(ze), lfhOffset, needsZip64Extra);
}

代码示例来源:origin: org.apache.ant/ant

System.arraycopy(LZERO, 0, buf, LFH_ORIGINAL_SIZE_OFFSET, WORD);
} else { // Stored
  putLong(ze.getSize(), buf, LFH_COMPRESSED_SIZE_OFFSET);
  putLong(ze.getSize(), buf, LFH_ORIGINAL_SIZE_OFFSET);

代码示例来源:origin: org.apache.ant/ant

if (entry.entry.getSize() != bytesWritten) {
  throw new ZipException("bad size for entry "
              + entry.entry.getName() + ": "
              + entry.entry.getSize()
              + " instead of "
              + bytesWritten);

代码示例来源:origin: org.apache.ant/ant

&& getExternalAttributes() == other.getExternalAttributes()
&& getMethod() == other.getMethod()
&& getSize() == other.getSize()
&& getCrc() == other.getCrc()
&& getCompressedSize() == other.getCompressedSize()

代码示例来源:origin: org.apache.ant/ant

|| ze.getSize() >= ZIP64_MAGIC) {
  ZipLong.ZIP64_MAGIC.putLong(buf, CFH_COMPRESSED_SIZE_OFFSET);
  ZipLong.ZIP64_MAGIC.putLong(buf, CFH_ORIGINAL_SIZE_OFFSET);
} else {
  putLong(ze.getCompressedSize(), buf, CFH_COMPRESSED_SIZE_OFFSET);
  putLong(ze.getSize(), buf, CFH_ORIGINAL_SIZE_OFFSET);

代码示例来源:origin: org.apache.ant/ant

/**
 * If the entry needs Zip64 extra information inside the central
 * directory then configure its data.
 *
 * @param ze ZipEntry
 * @param lfhOffset long
 * @param needsZip64Extra boolean
 */
private void handleZip64Extra(ZipEntry ze, long lfhOffset,
               boolean needsZip64Extra) {
  if (needsZip64Extra) {
    Zip64ExtendedInformationExtraField z64 = getZip64Extra(ze);
    if (ze.getCompressedSize() >= ZIP64_MAGIC
      || ze.getSize() >= ZIP64_MAGIC) {
      z64.setCompressedSize(new ZipEightByteInteger(ze.getCompressedSize()));
      z64.setSize(new ZipEightByteInteger(ze.getSize()));
    } else {
      // reset value that may have been set for LFH
      z64.setCompressedSize(null);
      z64.setSize(null);
    }
    if (lfhOffset >= ZIP64_MAGIC) {
      z64.setRelativeHeaderOffset(new ZipEightByteInteger(lfhOffset));
    }
    ze.setExtra();
  }
}

代码示例来源:origin: org.apache.ant/ant

ZipEightByteInteger compressedSize = ZipEightByteInteger.ZERO;
if (entry.entry.getMethod() == STORED
  && entry.entry.getSize() != -1) {
  size = new ZipEightByteInteger(entry.entry.getSize());
  compressedSize = size;

代码示例来源:origin: org.apache.ant/ant

if (!hasZip64Extra(entry.entry) || !actuallyNeedsZip64) {
  writeOut(ZipLong.getBytes(entry.entry.getCompressedSize()));
  writeOut(ZipLong.getBytes(entry.entry.getSize()));
} else {
  writeOut(ZipLong.ZIP64_MAGIC.getBytes());
  writeOut(ZipEightByteInteger.getBytes(entry.entry.getSize()));
  writeOut(ZipEightByteInteger.getBytes(entry.entry.getCompressedSize()));

代码示例来源:origin: org.apache.ant/ant

/**
 * Writes the data descriptor entry.
 *
 * @param ze the entry to write
 * @throws IOException on error
 * @since 1.1
 */
protected void writeDataDescriptor(ZipEntry ze) throws IOException {
  if (ze.getMethod() != DEFLATED || raf != null) {
    return;
  }
  writeCounted(DD_SIG);
  writeCounted(ZipLong.getBytes(ze.getCrc()));
  if (!hasZip64Extra(ze)) {
    writeCounted(ZipLong.getBytes(ze.getCompressedSize()));
    writeCounted(ZipLong.getBytes(ze.getSize()));
  } else {
    writeCounted(ZipEightByteInteger.getBytes(ze.getCompressedSize()));
    writeCounted(ZipEightByteInteger.getBytes(ze.getSize()));
  }
}

代码示例来源:origin: org.apache.ant/ant

ze.getExtraField(Zip64ExtendedInformationExtraField.HEADER_ID);
if (z64 != null) {
  final boolean hasUncompressedSize = ze.getSize() == ZIP64_MAGIC;
  final boolean hasCompressedSize = ze.getCompressedSize() == ZIP64_MAGIC;
  final boolean hasRelativeHeaderOffset =
    ze.setSize(z64.getSize().getLongValue());
  } else if (hasCompressedSize) {
    z64.setSize(new ZipEightByteInteger(ze.getSize()));

代码示例来源:origin: org.apache.ant/ant

private void setEntry(ZipEntry e) {
  if (e == null) {
    setExists(false);
    return;
  }
  setName(e.getName());
  setExists(true);
  setLastModified(e.getTime());
  setDirectory(e.isDirectory());
  setSize(e.getSize());
  setMode(e.getUnixMode());
  extras = e.getExtraFields(true);
  method = e.getMethod();
}

代码示例来源:origin: org.gradle/gradle-core

public long getSize() {
  return entry.getSize();
}

代码示例来源:origin: com.github.javahaohao/utils

.append(df.format(entry.getSize() / 1024.0))
      .append(" KB!").append("\r\n");
} else {
  long entrytime = entry.getTime();
  long localtime = destFile.lastModified();
  long entrysize = entry.getSize();
  long localsize = destFile.length();
  if (entrytime != localtime || entrysize != localsize) {

相关文章