addFile method

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

Implementation

@override
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),
    file.lengthSync(),
    fileStream,
  );

  if (level == store) {
    archiveFile.compress = false;
  }

  archiveFile.lastModTime = file.lastModifiedSync().millisecondsSinceEpoch;
  archiveFile.mode = file.statSync().mode;

  _encoder.addFile(archiveFile);
  await fileStream.close();
}