/** * 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)); }
/** * Unfortunately {@link java.util.zip.ZipOutputStream * java.util.zip.ZipOutputStream} seems to access the extra data * directly, so overriding getExtra doesn't help - we need to * modify super's data directly. * * @since 1.1 */ protected void setExtra() { super.setExtra(ExtraFieldUtils.mergeLocalFileDataData(getExtraFields(true))); }
/** * Add a file entry. */ private void addResource(final Resource r, final String name, final String prefix, final ZipOutputStream zOut, final int mode, final ZipFile zf, final File fromArchive) throws IOException { if (zf != null) { final ZipEntry ze = zf.getEntry(r.getName()); if (ze != null) { final boolean oldCompress = doCompress; if (keepCompression) { doCompress = (ze.getMethod() == ZipEntry.DEFLATED); } try (final BufferedInputStream is = new BufferedInputStream(zf.getInputStream(ze))) { zipFile(is, zOut, prefix + name, ze.getTime(), fromArchive, mode, ze.getExtraFields(true)); } finally { doCompress = oldCompress; } } } else { try (final BufferedInputStream is = new BufferedInputStream(r.getInputStream())) { zipFile(is, zOut, prefix + name, r.getLastModified(), fromArchive, mode, r instanceof ZipResource ? ((ZipResource) r).getExtraFields() : null); } } }
private void setEntry(ZipEntry e) { if (e == null) { setExists(false); return; } setName(e.getName()); setExists(true); setLastModified(e.getTime()); setDirectory(e.isDirectory()); setSize(e.getSize()); setMode(e.getUnixMode()); extras = e.getExtraFields(true); method = e.getMethod(); }