Java源码示例:org.apache.commons.compress.archivers.ar.ArArchiveOutputStream
示例1
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 );
}
示例2
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 );
}
示例3
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 + "'");
}
}
示例4
@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);
}
}
示例5
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 + "'");
}
}
示例6
@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);
}
}
示例7
public Ar() {
getArchiveExtension().convention("ar");
longFileMode.convention(ArArchiveOutputStream.LONGFILE_ERROR);
}
示例8
public Ar() {
getArchiveExtension().convention("ar");
longFileMode.convention(ArArchiveOutputStream.LONGFILE_ERROR);
}