本文整理汇总了Java中org.apache.commons.compress.archivers.ArchiveEntry.SIZE_UNKNOWN属性的典型用法代码示例。如果您正苦于以下问题:Java ArchiveEntry.SIZE_UNKNOWN属性的具体用法?Java ArchiveEntry.SIZE_UNKNOWN怎么用?Java ArchiveEntry.SIZE_UNKNOWN使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.commons.compress.archivers.ArchiveEntry
的用法示例。
在下文中一共展示了ArchiveEntry.SIZE_UNKNOWN属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validateSizeInformation
/**
* 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(Zip64Mode effectiveMode)
throws ZipException {
// Size/CRC not required if RandomAccessFile is used
if (entry.entry.getMethod() == STORED && raf == 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() == -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));
}
}
示例2: putArchiveEntry
public void putArchiveEntry(ArchiveEntry archiveEntry, byte[] originalData) throws IOException {
if (finished) {
throw new IOException("Stream has already been finished");
}
if (entry != null) {
closeArchiveEntry();
}
entry = new CurrentEntry((ZipArchiveEntry) archiveEntry);
entries.add(entry.entry);
setDefaults(entry.entry);
final Zip64Mode effectiveMode = getEffectiveZip64Mode(entry.entry);
validateSizeInformation(effectiveMode);
if (shouldAddZip64Extra(entry.entry, effectiveMode)) {
Zip64ExtendedInformationExtraField z64 = getZip64Extra(entry.entry);
// just a placeholder, real data will be in data
// descriptor or inserted later via RandomAccessFile
ZipEightByteInteger size = ZipEightByteInteger.ZERO;
if (entry.entry.getMethod() == STORED
&& entry.entry.getSize() != ArchiveEntry.SIZE_UNKNOWN) {
// actually, we already know the sizes
size = new ZipEightByteInteger(entry.entry.getSize());
}
z64.setSize(size);
z64.setCompressedSize(size);
entry.entry.setExtra();
}
if (entry.entry.getMethod() == DEFLATED && hasCompressionLevelChanged) {
def.setLevel(level);
hasCompressionLevelChanged = false;
}
writeLocalFileHeader(entry.entry, originalData);
}
示例3: getEffectiveZip64Mode
/**
* 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.
*
* @since 1.3
*/
private Zip64Mode getEffectiveZip64Mode(ZipArchiveEntry ze) {
if (zip64Mode != Zip64Mode.AsNeeded
|| raf != null
|| ze.getMethod() != DEFLATED
|| ze.getSize() != ArchiveEntry.SIZE_UNKNOWN) {
return zip64Mode;
}
return Zip64Mode.Never;
}
示例4: shouldAddZip64Extra
/**
* Whether to addd 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>
*/
private boolean shouldAddZip64Extra(ZipArchiveEntry entry, Zip64Mode mode) {
return mode == Zip64Mode.Always
|| entry.getSize() >= ZIP64_MAGIC
|| entry.getCompressedSize() >= ZIP64_MAGIC
|| (entry.getSize() == ArchiveEntry.SIZE_UNKNOWN
&& raf != null && mode != Zip64Mode.Never);
}