addFile method

Future<void> addFile(
  1. File file, [
  2. String? filename,
  3. int? level = gzip
])

Implementation

Future<void> addFile(File file, [String? filename, int? level = gzip]) async {
  final fileStream = InputFileStream(file.path);
  final archiveFile =
      ArchiveFile.stream(filename ?? path.basename(file.path), fileStream);

  if (level == store) {
    archiveFile.compression = CompressionType.none;
  }

  archiveFile.lastModTime =
      (await file.lastModified()).millisecondsSinceEpoch ~/ 1000;

  archiveFile.mode = (await file.stat()).mode;

  _encoder.add(archiveFile);

  await fileStream.close();
}