當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。