zipDirectory method
void
zipDirectory(})
Zips a dir
to a Zip file synchronously.
filename
determines where the Zip file will be created. If filename
is not specified, the name of the directory will be used with a '.zip'
extension. If filename
is within dir
, it will throw a FormatException.
See also:
- zipDirectoryAsync for the asynchronous version of this method.
_composeZipDirectoryPath
for the logic of composing the Zip file path.
Implementation
@override
void zipDirectory(
Directory dir, {
String? filename,
int? level,
bool followLinks = true,
DateTime? modified,
void Function(double)? onProgress,
}) {
final dirPath = dir.path;
final zipPath = filename ?? '$dirPath.zip';
level ??= gzip;
create(zipPath, level: level);
addDirectory(
dir,
includeDirName: false,
level: level,
followLinks: followLinks,
);
close();
}