createArchiveFile function
Future<ArchiveWriter>
createArchiveFile(
- String path, {
- required ArchiveWriteFormat format,
- ArchiveWriteOptions options = const ArchiveWriteOptions(),
Creates a writer that appends a new archive of format to the file at
path (Phase 2), creating or truncating it.
Sugar for Archive.create over a FileByteSink. Add entries, then call
close() on the returned writer, which also flushes and closes the
file. On failure to open the file, no writer is returned.
Implementation
Future<ArchiveWriter> createArchiveFile(
String path, {
required ArchiveWriteFormat format,
ArchiveWriteOptions options = const ArchiveWriteOptions(),
}) async {
final sink = await FileByteSink.create(path);
try {
return _ClosingWriter(
Archive.create(sink, format: format, options: options),
sink,
);
} catch (_) {
await sink.close();
rethrow;
}
}