gpt4 book ai didi

org.apache.commons.compress.archivers.zip.ZipArchiveEntry.getCrc()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-17 08:30:40 24 4
gpt4 key购买 nike

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

ZipArchiveEntry.getCrc介绍

暂无

代码示例

代码示例来源:origin: org.apache.commons/commons-compress

if (entry.entry.getCrc() != crc) {
  throw new ZipException("bad CRC checksum for entry "
              + entry.entry.getName() + ": "
              + Long.toHexString(entry.entry.getCrc())
              + " instead of "
              + Long.toHexString(crc));

代码示例来源:origin: org.apache.commons/commons-compress

&& getMethod() == other.getMethod()
&& getSize() == other.getSize()
&& getCrc() == other.getCrc()
&& getCompressedSize() == other.getCompressedSize()
&& Arrays.equals(getCentralDirectoryExtra(),

代码示例来源:origin: org.apache.commons/commons-compress

putLong(ze.getCrc(), buf, LFH_CRC_OFFSET);
} else if (zipMethod == DEFLATED || channel != null) {
  System.arraycopy(LZERO, 0, buf, LFH_CRC_OFFSET, WORD);
} else {
  putLong(ze.getCrc(), buf, LFH_CRC_OFFSET);

代码示例来源:origin: org.apache.commons/commons-compress

putLong(ze.getCrc(), buf, CFH_CRC_OFFSET);
if (ze.getCompressedSize() >= ZIP64_MAGIC
    || ze.getSize() >= ZIP64_MAGIC

代码示例来源:origin: org.apache.commons/commons-compress

/**
 * Adds an archive entry with a raw input stream.
 *
 * If crc, size and compressed size are supplied on the entry, these values will be used as-is.
 * Zip64 status is re-established based on the settings in this stream, and the supplied value
 * is ignored.
 *
 * The entry is put and closed immediately.
 *
 * @param entry The archive entry to add
 * @param rawStream The raw input stream of a different entry. May be compressed/encrypted.
 * @throws IOException If copying fails
 */
public void addRawArchiveEntry(final ZipArchiveEntry entry, final InputStream rawStream)
    throws IOException {
  final ZipArchiveEntry ae = new ZipArchiveEntry(entry);
  if (hasZip64Extra(ae)) {
    // Will be re-added as required. this may make the file generated with this method
    // somewhat smaller than standard mode,
    // since standard mode is unable to remove the zip 64 header.
    ae.removeExtraField(Zip64ExtendedInformationExtraField.HEADER_ID);
  }
  final boolean is2PhaseSource = ae.getCrc() != ZipArchiveEntry.CRC_UNKNOWN
      && ae.getSize() != ArchiveEntry.SIZE_UNKNOWN
      && ae.getCompressedSize() != ArchiveEntry.SIZE_UNKNOWN;
  putArchiveEntry(ae, is2PhaseSource);
  copyFromZipInputStream(rawStream);
  closeCopiedEntry(is2PhaseSource);
}

代码示例来源:origin: org.apache.commons/commons-compress

/**
 * 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.
 */
private void validateSizeInformation(final Zip64Mode effectiveMode)
  throws ZipException {
  // Size/CRC not required if SeekableByteChannel is used
  if (entry.entry.getMethod() == STORED && channel == null) {
    if (entry.entry.getSize() == ArchiveEntry.SIZE_UNKNOWN) {
      throw new ZipException("uncompressed size is required for"
                  + " STORED method when not writing to a"
                  + " file");
    }
    if (entry.entry.getCrc() == ZipArchiveEntry.CRC_UNKNOWN) {
      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.commons/commons-compress

/**
 * Writes the data descriptor entry.
 * @param ze the entry to write
 * @throws IOException on error
 */
protected void writeDataDescriptor(final ZipArchiveEntry ze) throws IOException {
  if (!usesDataDescriptor(ze.getMethod(), false)) {
    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.commons/commons-compress

writeOut(ZipLong.getBytes(entry.entry.getCrc()));
if (!hasZip64Extra(entry.entry) || !actuallyNeedsZip64) {
  writeOut(ZipLong.getBytes(entry.entry.getCompressedSize()));

代码示例来源:origin: de.unkrig/de-unkrig-commons

/**
 * @return     The CRC32 (0...0xffffffffL) of the contents of the given archive entry, or -1L if unknown
 * @deprecated Should be replaced by a new method {@code ArchiveEntry.getCrc32()}
 */
@Deprecated public static long
getEntryCrc32(ArchiveEntry archiveEntry) {
  if (archiveEntry instanceof ZipArchiveEntry) return ((ZipArchiveEntry) archiveEntry).getCrc();
  if (archiveEntry instanceof SevenZArchiveEntry) {
    SevenZArchiveEntry szae = (SevenZArchiveEntry) archiveEntry;
    return szae.getHasCrc() ? 0xffffffffL & szae.getCrcValue() : -1;
  }
  return -1;
}

代码示例来源:origin: de.unkrig.commons/commons-file

/**
 * @return     The CRC32 (0...0xffffffffL) of the contents of the given archive entry, or -1L if unknown
 * @deprecated Should be replaced by a new method {@code ArchiveEntry.getCrc32()}
 */
@Deprecated public static long
getEntryCrc32(ArchiveEntry archiveEntry) {
  if (archiveEntry instanceof ZipArchiveEntry) return ((ZipArchiveEntry) archiveEntry).getCrc();
  if (archiveEntry instanceof SevenZArchiveEntry) {
    SevenZArchiveEntry szae = (SevenZArchiveEntry) archiveEntry;
    return szae.getHasCrc() ? 0xffffffffL & szae.getCrcValue() : -1;
  }
  return -1;
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

if (entry.entry.getCrc() != crc) {
  throw new ZipException("bad CRC checksum for entry "
              + entry.entry.getName() + ": "
              + Long.toHexString(entry.entry.getCrc())
              + " instead of "
              + Long.toHexString(crc));

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

&& getMethod() == other.getMethod()
&& getSize() == other.getSize()
&& getCrc() == other.getCrc()
&& getCompressedSize() == other.getCompressedSize()
&& Arrays.equals(getCentralDirectoryExtra(),

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

putLong(ze.getCrc(), buf, LFH_CRC_OFFSET);
} else if (zipMethod == DEFLATED || channel != null) {
  System.arraycopy(LZERO, 0, buf, LFH_CRC_OFFSET, WORD);
} else {
  putLong(ze.getCrc(), buf, LFH_CRC_OFFSET);

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

putLong(ze.getCrc(), buf, CFH_CRC_OFFSET);
if (ze.getCompressedSize() >= ZIP64_MAGIC
    || ze.getSize() >= ZIP64_MAGIC

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

/**
 * Adds an archive entry with a raw input stream.
 *
 * If crc, size and compressed size are supplied on the entry, these values will be used as-is.
 * Zip64 status is re-established based on the settings in this stream, and the supplied value
 * is ignored.
 *
 * The entry is put and closed immediately.
 *
 * @param entry The archive entry to add
 * @param rawStream The raw input stream of a different entry. May be compressed/encrypted.
 * @throws IOException If copying fails
 */
public void addRawArchiveEntry(final ZipArchiveEntry entry, final InputStream rawStream)
    throws IOException {
  final ZipArchiveEntry ae = new ZipArchiveEntry(entry);
  if (hasZip64Extra(ae)) {
    // Will be re-added as required. this may make the file generated with this method
    // somewhat smaller than standard mode,
    // since standard mode is unable to remove the zip 64 header.
    ae.removeExtraField(Zip64ExtendedInformationExtraField.HEADER_ID);
  }
  final boolean is2PhaseSource = ae.getCrc() != ZipArchiveEntry.CRC_UNKNOWN
      && ae.getSize() != ArchiveEntry.SIZE_UNKNOWN
      && ae.getCompressedSize() != ArchiveEntry.SIZE_UNKNOWN;
  putArchiveEntry(ae, is2PhaseSource);
  copyFromZipInputStream(rawStream);
  closeCopiedEntry(is2PhaseSource);
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

/**
 * 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.
 */
private void validateSizeInformation(final Zip64Mode effectiveMode)
  throws ZipException {
  // Size/CRC not required if SeekableByteChannel is used
  if (entry.entry.getMethod() == STORED && channel == null) {
    if (entry.entry.getSize() == ArchiveEntry.SIZE_UNKNOWN) {
      throw new ZipException("uncompressed size is required for"
                  + " STORED method when not writing to a"
                  + " file");
    }
    if (entry.entry.getCrc() == ZipArchiveEntry.CRC_UNKNOWN) {
      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: com.impetus.fabric/fabric-jdbc-driver-shaded

/**
 * Writes the data descriptor entry.
 * @param ze the entry to write
 * @throws IOException on error
 */
protected void writeDataDescriptor(final ZipArchiveEntry ze) throws IOException {
  if (!usesDataDescriptor(ze.getMethod(), false)) {
    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: com.impetus.fabric/fabric-jdbc-driver-shaded

writeOut(ZipLong.getBytes(entry.entry.getCrc()));
if (!hasZip64Extra(entry.entry) || !actuallyNeedsZip64) {
  writeOut(ZipLong.getBytes(entry.entry.getCompressedSize()));

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com