当前位置: 首页>>代码示例>>Java>>正文


Java ArchiveEntry.SIZE_UNKNOWN属性代码示例

本文整理汇总了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));
    }
}
 
开发者ID:AndroidVTS,项目名称:android-vts,代码行数:29,代码来源:ModdedZipArchiveOutputStream.java

示例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);
}
 
开发者ID:AndroidVTS,项目名称:android-vts,代码行数:40,代码来源:ModdedZipArchiveOutputStream.java

示例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;
}
 
开发者ID:AndroidVTS,项目名称:android-vts,代码行数:16,代码来源:ModdedZipArchiveOutputStream.java

示例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);
}
 
开发者ID:AndroidVTS,项目名称:android-vts,代码行数:21,代码来源:ModdedZipArchiveOutputStream.java


注:本文中的org.apache.commons.compress.archivers.ArchiveEntry.SIZE_UNKNOWN属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。