@Override public void writeEntry(OutputStream outputStream) throws IOException { entry.writeEntry(outputStream); } }
public UnArchiver build() { return new UnArchiver(includes, excludes, useRoot, flatten, posixLongFileMode); } }
private void archive(File jar, List<Iterable<Entry>> sources) throws IOException { Archiver archiver = Archiver.builder() // .useRoot(false) // .normalize(true) // .build(); archiver.archive(jar, new AggregateSource(sources)); if (logger.isDebugEnabled()) { int size = 0; for (Iterable<?> source : sources) { size += size(source); } logger.debug("Created archive {} with {} entries", jar, size); } }
@Override public ExtendedArchiveEntry createEntryFor(String entryName, Entry archiveEntry, boolean isExecutable) { ExtendedArchiveEntry entry = newEntry(entryName, archiveEntry); entry.setSize(archiveEntry.getSize()); // // If we have a valid file mode then use it for the entry we are creating if (archiveEntry.getFileMode() != -1) { entry.setFileMode(archiveEntry.getFileMode()); if (isExecutable) { entry.setFileMode(FileMode.makeExecutable(entry.getFileMode())); } } else { if (isExecutable) { entry.setFileMode(FileMode.EXECUTABLE_FILE.getBits()); } } return entry; } }
public void archive(File archive, File... sourceDirectories) throws IOException { archive(archive, new DirectorySource(sourceDirectories)); }
@Override public boolean apply(Entry input) { return entryNames.add(input.getName()); } };
public ArchiverBuilder executable(String... executables) { return executable(ImmutableList.copyOf(executables)); }
public TarGzArchiveSource(File archive) { closer = Closer.create(); try { archiveInputStream = closer.register(ArchiverHelper.getArchiveHandler(archive, false).getInputStream()); } catch (IOException e) { throw new RuntimeException(String.format("Cannot determine the type of archive %s.", archive), e); } }
private void writeEntry(ExtendedArchiveEntry entry, ArchiveOutputStream aos) throws IOException { aos.putArchiveEntry(entry); if (!entry.isDirectory()) { entry.writeEntry(aos); } aos.closeArchiveEntry(); }
public UnArchiver(List<String> includes, List<String> excludes, boolean useRoot, boolean flatten, boolean posixLongFileMode) { this.useRoot = useRoot; this.flatten = flatten; this.selector = new Selector(includes, excludes); this.posixLongFileMode = posixLongFileMode; }
public Archiver build() { return new Archiver(includes, excludes, executables, useRoot, flatten, normalize, prefix, posixLongFileMode); } }
public static UnArchiverBuilder builder() { return new UnArchiverBuilder(); }
public static ArchiverBuilder builder() { return new ArchiverBuilder(); }
/** * Returns the time for a new Jar file entry in milliseconds since the epoch. Uses {@link JarCreator#DOS_EPOCH_IN_JAVA_TIME} for normalized entries, {@link System#currentTimeMillis()} otherwise. * * @param filename The name of the file for which we are entering the time * @return the time for a new Jar file entry in milliseconds since the epoch. */ private long newEntryTimeMillis(String filename) { return normalize ? normalizedTimestamp(filename) : System.currentTimeMillis(); }
public ArchiverBuilder includes(String... includes) { return includes(ImmutableList.copyOf(includes)); }
public ArchiverBuilder excludes(String... excludes) { return excludes(ImmutableList.copyOf(excludes)); }
@Override public void writeEntry(OutputStream outputStream) throws IOException { entry.writeEntry(outputStream); } }
@Override public boolean apply(Entry input) { return entryNames.add(input.getName()); } };
private Archiver(List<String> includes, List<String> excludes, List<String> executables, boolean useRoot, boolean flatten, boolean normalize, String prefix, boolean posixLongFileMode) { this.executables = executables; this.useRoot = useRoot; this.flatten = flatten; this.normalize = normalize; this.prefix = prefix; this.posixLongFileMode = posixLongFileMode; this.selector = new Selector(includes, excludes); }