createArchiveZipAsync static method

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

Implementation

static Future<File> createArchiveZipAsync({
  required Directory directory,
  required String? password,
  required File outPutFile,
  DateTime? modified,
  required ArchiveGeneralLibOptions archiveGeneralLibOptions,
}) async {
  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) {
      await outPutFile.parent.create(recursive: true);
    }
    await outPutFile.writeAsBytes(result);
  }
  await archiveGeneralLib.closeAsync();

  return outPutFile;
}