Example usage for org.apache.commons.compress.archivers.zip UnixStat DIR_FLAG

List of usage examples for org.apache.commons.compress.archivers.zip UnixStat DIR_FLAG

Introduction

In this page you can find the example usage for org.apache.commons.compress.archivers.zip UnixStat DIR_FLAG.

Prototype

int DIR_FLAG

To view the source code for org.apache.commons.compress.archivers.zip UnixStat DIR_FLAG.

Click Source Link

Document

Indicates directories.

Usage

From source file:com.google.jenkins.plugins.persistentmaster.volume.zip.ZipCreator.java

private void copyDirectory(String filenameInZip) throws IOException {
    logger.finer("Adding directory: " + filenameInZip);
    // entries ending in / indicate a directory
    ZipArchiveEntry entry = new ZipArchiveEntry(filenameInZip + "/");
    // in addition, set the unix directory flag
    entry.setUnixMode(entry.getUnixMode() | UnixStat.DIR_FLAG);
    zipStream.putArchiveEntry(entry);/*from   w w w .  j  a  va 2s.  com*/
    zipStream.closeArchiveEntry();
}

From source file:org.springframework.boot.gradle.tasks.bundling.BootZipCopyAction.java

private void writeDirectory(ZipArchiveEntry entry, ZipArchiveOutputStream out) throws IOException {
    prepareEntry(entry, UnixStat.DIR_FLAG | UnixStat.DEFAULT_DIR_PERM);
    out.putArchiveEntry(entry);//from ww  w . j a  v a 2 s.co m
    out.closeArchiveEntry();
}

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./*from  ww  w . j av  a 2  s.c  o 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();
    }
}