@Override public void putNextEntry(ZipEntry ze) throws IOException { ze.setTime(dirTime+1999); // roundup super.putNextEntry(ze); } }) {
public void close() throws IOException { zip.close(); }
ZipArchiver(OutputStream out) { zip = new ZipOutputStream(out); zip.setEncoding(System.getProperty("file.encoding")); zip.setUseZip64(Zip64Mode.AsNeeded); }
private ByteBuffer getName(ZipEntry ze) throws IOException { return getEntryEncoding(ze).encode(ze.getName()); }
/** * The actual data to put into central directory. * * @return The CentralDirectoryData value */ public byte[] getCentralDirectoryData() { return centralDirectoryData == null ? getLocalFileDataData() : ZipUtil.copy(centralDirectoryData); }
/** * Length of the complete extra field in the central directory. * * @return The CentralDirectoryLength value */ public ZipShort getCentralDirectoryLength() { return centralDirectoryData == null ? getLocalFileDataLength() : new ZipShort(centralDirectoryData.length); }
/** {@inheritDoc} */ public ZipShort getCentralDirectoryLength() { if (data == null) { assembleData(); } return new ZipShort(data.length); }
/** * Retrieves the extra data for the central directory. * * @return the central directory extra data * @since 1.1 */ public byte[] getCentralDirectoryExtra() { return ExtraFieldUtils.mergeCentralDirectoryData(getExtraFields(true)); }
/** * Get the central data. * @return the central data if present, else return the local file data */ public byte[] getCentralDirectoryData() { if (centralData != null) { return ZipUtil.copy(centralData); } return getLocalFileDataData(); }
private GeneralPurposeBit getGeneralPurposeBits(final int zipMethod, final boolean utfFallback) { GeneralPurposeBit b = new GeneralPurposeBit(); b.useUTF8ForNames(useUTF8Flag || utfFallback); if (isDeflatedToOutputStream(zipMethod)) { b.useDataDescriptor(true); } return b; }
/** * Get the central data length. * If there is no central data, get the local file data length. * @return the central data length */ public ZipShort getCentralDirectoryLength() { if (centralData != null) { return new ZipShort(centralData.length); } return getLocalFileDataLength(); }
/** * Whether this library supports the encryption used by the given * entry. * * @return true if the entry isn't encrypted at all */ private static boolean supportsEncryptionOf(ZipEntry entry) { return !entry.getGeneralPurposeBit().usesEncryption(); }
/** * Indicate that this entry is a symbolic link to the given filename. * * @param name Name of the file this entry links to, empty String * if it is not a symbolic link. * * @since 1.1 */ public void setLinkedFile(String name) { link = name; mode = getMode(mode); }
/** * Set the extra field data in central directory. * @param data the data to use */ public void setCentralDirectoryData(byte[] data) { centralData = ZipUtil.copy(data); }
/** * Split the array into ExtraFields and populate them with the * given data as local file data, throwing an exception if the * data cannot be parsed. * @param data an array of bytes as it appears in local file data * @return an array of ExtraFields * @throws ZipException on error */ public static ZipExtraField[] parse(byte[] data) throws ZipException { return parse(data, true, UnparseableExtraField.THROW); }
/** * Retrieves all extra fields that have been parsed successfully. * * @return an array of the extra fields */ public ZipExtraField[] getExtraFields() { return getParseableExtraFields(); }
/** * Create instance from the eight bytes starting at offset. * @param bytes the bytes to store as a ZipEightByteInteger * @param offset the offset to start */ public ZipEightByteInteger(byte[] bytes, int offset) { value = ZipEightByteInteger.getValue(bytes, offset); }
/** * whether the current entry will be encrypted using strong encryption * * @param b boolean */ public void useStrongEncryption(boolean b) { strongEncryptionFlag = b; if (b) { useEncryption(true); } }
/** * Encodes the set bits in a form suitable for ZIP archives. * * @return byte[] */ public byte[] encode() { byte[] result = new byte[2]; encode(result, 0); return result; }