tarDirectory method
Implementation
Future<void> tarDirectory(Directory dir,
{int compression = store,
String? filename,
bool followLinks = true,
int? level,
ZipFileProgress? filter}) async {
final dirPath = dir.path;
if (compression == gzip || compression == zstd) {
await _tarDirectoryCompressed(
dir,
filename ??
(compression == gzip ? '$dirPath.tar.gz' : '$dirPath.tar.zst'),
compression: compression,
level: level,
followLinks: followLinks,
filter: filter,
);
return;
}
// An uncompressed TAR still writes directly to the target file.
open(filename ?? '$dirPath.tar');
try {
await addDirectory(dir, followLinks: followLinks, filter: filter);
} finally {
await close();
}
}