createArchiveZip static method

File createArchiveZip({
  1. required Directory directory,
  2. required String? password,
  3. required File outPutFile,
  4. DateTime? modified,
  5. required ArchiveGeneralLibOptions archiveGeneralLibOptions,
})

create archive zip

Implementation

static File createArchiveZip({
  required Directory directory,
  required String? password,
  required File outPutFile,
  DateTime? modified,
  required ArchiveGeneralLibOptions archiveGeneralLibOptions,
}) {
  final ArchiveGeneralLib archiveGeneralLib = ArchiveGeneralLib();
  archiveGeneralLib.addFilesByDirectory(
    directory: directory,
    archiveGeneralLibOptions: archiveGeneralLibOptions,
    directoryBase: directory,
  );
  final result = archiveGeneralLib.toZipBytes(
    password: password,
    modified: modified,
  );
  if (result != null) {
    if (outPutFile.parent.existsSync() == false) {
      outPutFile.parent.createSync(recursive: true);
    }
    outPutFile.writeAsBytesSync(result);
  }
  archiveGeneralLib.close();

  return outPutFile;
}