zipDirectory method

void zipDirectory(
  1. Directory dir, {
  2. String? filename,
  3. int? level,
  4. bool followLinks = true,
  5. void onProgress(
    1. double
    )?,
  6. DateTime? modified,
})

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

//@Deprecated('Use zipDirectoryAsync instead')
void zipDirectory(Directory dir,
    {String? filename,
    int? level,
    bool followLinks = true,
    void Function(double)? onProgress,
    DateTime? modified}) {
  create(
    _composeZipDirectoryPath(dir: dir, filename: filename),
    level: level ??= GZIP,
    modified: modified,
  );

  _addDirectory(
    dir,
    includeDirName: false,
    level: level,
    followLinks: followLinks,
    onProgress: onProgress,
  );
  closeSync();
}