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

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

Introduction

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

Prototype

int FILE_FLAG

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

Click Source Link

Document

Indicates plain files.

Usage

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

private void writeClass(ZipArchiveEntry entry, ZipInputStream in, ZipArchiveOutputStream out)
        throws IOException {
    prepareEntry(entry, UnixStat.FILE_FLAG | UnixStat.DEFAULT_FILE_PERM);
    out.putArchiveEntry(entry);/*from  w  ww.  ja v a 2  s.  c om*/
    byte[] buffer = new byte[4096];
    int read;
    while ((read = in.read(buffer)) > 0) {
        out.write(buffer, 0, read);
    }
    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 w ww. jav  a2s .  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();
    }
}