tarWritingSink function
StreamSink<TarEntry>
tarWritingSink(
- StreamSink<
List< output, {int> > - OutputFormat format = OutputFormat.pax,
Create a sink emitting encoded tar files to the output
sink.
For instance, you can use this to write a tar file:
import 'dart:convert';
import 'dart:io';
import 'package:tar/tar.dart';
Future<void> main() async {
Stream<TarEntry> entries = Stream.value(
TarEntry.data(
TarHeader(
name: 'example.txt',
mode: int.parse('644', radix: 8),
),
utf8.encode('This is the content of the tar file'),
),
);
final output = File('/tmp/test.tar').openWrite();
await entries.pipe(tarWritingSink(output));
}
Note that, if you don't set the TarHeader.size, outgoing tar entries need to be buffered once, which decreases performance.
The format
argument can be used to control how long file names are written
in the tar archive. For more details, see the options in OutputFormat.
See also:
- tarWriter, a stream transformer using this sink
- StreamSink
Implementation
StreamSink<TarEntry> tarWritingSink(StreamSink<List<int>> output,
{OutputFormat format = OutputFormat.pax}) {
return _WritingSink(output, format);
}