org.apache.commons.compress.archivers.ar.ArArchiveOutputStream Java Examples

The following examples show how to use org.apache.commons.compress.archivers.ar.ArArchiveOutputStream. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DebianPackageWriter.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
public DebianPackageWriter ( final OutputStream stream, final GenericControlFile packageControlFile, final TimestampProvider timestampProvider ) throws IOException
{
    this.packageControlFile = packageControlFile;
    this.timestampProvider = timestampProvider;
    if ( getTimestampProvider () == null )
    {
        throw new IllegalArgumentException ( "'timestampProvider' must not be null" );
    }
    BinaryPackageControlFile.validate ( packageControlFile );

    this.ar = new ArArchiveOutputStream ( stream );

    this.ar.putArchiveEntry ( new ArArchiveEntry ( "debian-binary", this.binaryHeader.length, 0, 0, AR_ARCHIVE_DEFAULT_MODE, getTimestampProvider ().getModTime () / 1000 ) );
    this.ar.write ( this.binaryHeader );
    this.ar.closeArchiveEntry ();

    this.dataTemp = File.createTempFile ( "data", null );

    this.dataStream = new TarArchiveOutputStream ( new GZIPOutputStream ( new FileOutputStream ( this.dataTemp ) ) );
    this.dataStream.setLongFileMode ( TarArchiveOutputStream.LONGFILE_GNU );
}
 
Example #2
Source File: DebianPackageWriter.java    From packagedrone with Eclipse Public License 1.0 6 votes vote down vote up
public DebianPackageWriter ( final OutputStream stream, final BinaryPackageControlFile packageControlFile, final Supplier<Instant> timestampSupplier ) throws IOException
{
    Objects.requireNonNull ( timestampSupplier );

    this.timestampSupplier = timestampSupplier;
    this.packageControlFile = packageControlFile;
    BinaryPackageControlFile.validate ( packageControlFile );

    this.ar = new ArArchiveOutputStream ( stream );

    this.ar.putArchiveEntry ( new ArArchiveEntry ( "debian-binary", this.binaryHeader.length, 0, 0, AR_ARCHIVE_DEFAULT_MODE, timestampSupplier.get ().getEpochSecond () ) );
    this.ar.write ( this.binaryHeader );
    this.ar.closeArchiveEntry ();

    this.dataTemp = File.createTempFile ( "data", null );

    this.dataStream = new TarArchiveOutputStream ( new GZIPOutputStream ( new FileOutputStream ( this.dataTemp ) ) );
    this.dataStream.setLongFileMode ( TarArchiveOutputStream.LONGFILE_GNU );
}
 
Example #3
Source File: Ar.java    From gradle-plugins with MIT License 5 votes vote down vote up
public void setLongFileMode(String longFileMode) {
    if (longFileMode.equalsIgnoreCase("LONGFILE_ERROR") || longFileMode.equalsIgnoreCase("ERROR")) {
        this.longFileMode.set(ArArchiveOutputStream.LONGFILE_ERROR);
    } else if (longFileMode.equalsIgnoreCase("LONGFILE_BSD") || longFileMode.equalsIgnoreCase("BSD")) {
        this.longFileMode.set(ArArchiveOutputStream.LONGFILE_BSD);
    } else {
        throw new IllegalArgumentException("Expected 'LONGFILE_ERROR'/'ERROR' or 'LONGFILE_BSD'/'BSD', but was '" + longFileMode + "'");
    }
}
 
Example #4
Source File: Ar.java    From gradle-plugins with MIT License 5 votes vote down vote up
@SneakyThrows
private WorkResult execute(CopyActionProcessingStream copyActionProcessingStream) {
    try (ArArchiveOutputStream archiveOutputStream = new ArArchiveOutputStream(new FileOutputStream(getArchiveFile().get().getAsFile()))) {

        archiveOutputStream.setLongFileMode(this.longFileMode.get());

        copyActionProcessingStream.process(new StreamAction(archiveOutputStream));

        return WorkResults.didWork(true);
    }
}
 
Example #5
Source File: Ar.java    From gradle-plugins with MIT License 5 votes vote down vote up
public void setLongFileMode(String longFileMode) {
    if (longFileMode.equalsIgnoreCase("LONGFILE_ERROR") || longFileMode.equalsIgnoreCase("ERROR")) {
        this.longFileMode.set(ArArchiveOutputStream.LONGFILE_ERROR);
    } else if (longFileMode.equalsIgnoreCase("LONGFILE_BSD") || longFileMode.equalsIgnoreCase("BSD")) {
        this.longFileMode.set(ArArchiveOutputStream.LONGFILE_BSD);
    } else {
        throw new IllegalArgumentException("Expected 'LONGFILE_ERROR'/'ERROR' or 'LONGFILE_BSD'/'BSD', but was '" + longFileMode + "'");
    }
}
 
Example #6
Source File: Ar.java    From gradle-plugins with MIT License 5 votes vote down vote up
@SneakyThrows
private WorkResult execute(CopyActionProcessingStream copyActionProcessingStream) {
    try (ArArchiveOutputStream archiveOutputStream = new ArArchiveOutputStream(new FileOutputStream(getArchiveFile().get().getAsFile()))) {

        archiveOutputStream.setLongFileMode(this.longFileMode.get());

        copyActionProcessingStream.process(new StreamAction(archiveOutputStream));

        return WorkResults.didWork(true);
    }
}
 
Example #7
Source File: Ar.java    From gradle-plugins with MIT License 4 votes vote down vote up
public Ar() {
    getArchiveExtension().convention("ar");
    longFileMode.convention(ArArchiveOutputStream.LONGFILE_ERROR);
}
 
Example #8
Source File: Ar.java    From gradle-plugins with MIT License 4 votes vote down vote up
public Ar() {
    getArchiveExtension().convention("ar");
    longFileMode.convention(ArArchiveOutputStream.LONGFILE_ERROR);
}