List of usage examples for org.apache.commons.compress.archivers.jar JarArchiveEntry setUnixMode
public void setUnixMode(int mode)
From source file:org.springframework.boot.loader.tools.JarWriter.java
/** * Perform the actual write of a {@link JarEntry}. All other write methods delegate to * this one.//w ww .ja va 2s.co m * @param entry the entry to write * @param entryWriter the entry writer or {@code null} if there is no content * @param unpackHandler handles possible unpacking for the entry * @throws IOException in case of I/O errors */ private void writeEntry(JarArchiveEntry entry, EntryWriter entryWriter, UnpackHandler unpackHandler) throws IOException { String parent = entry.getName(); if (parent.endsWith("/")) { parent = parent.substring(0, parent.length() - 1); entry.setUnixMode(UnixStat.DIR_FLAG | UnixStat.DEFAULT_DIR_PERM); } else { entry.setUnixMode(UnixStat.FILE_FLAG | UnixStat.DEFAULT_FILE_PERM); } if (parent.lastIndexOf('/') != -1) { parent = parent.substring(0, parent.lastIndexOf('/') + 1); if (!parent.isEmpty()) { writeEntry(new JarArchiveEntry(parent), null, unpackHandler); } } if (this.writtenEntries.add(entry.getName())) { entryWriter = addUnpackCommentIfNecessary(entry, entryWriter, unpackHandler); this.jarOutput.putArchiveEntry(entry); if (entryWriter != null) { entryWriter.write(this.jarOutput); } this.jarOutput.closeArchiveEntry(); } }