add method Null safety

void add(
  1. ArchiveFile file
)

Implementation

void add(ArchiveFile file) {
  if (_outputStream == null) {
    return;
  }

  // GNU tar files store extra long file names in a separate file
  if (file.name.length > 100) {
    final ts = TarFile();
    ts.filename = '././@LongLink';
    ts.fileSize = file.name.length;
    ts.mode = 0;
    ts.ownerId = 0;
    ts.groupId = 0;
    ts.lastModTime = 0;
    ts.content = file.name.codeUnits;
    ts.write(_outputStream);
  }

  final ts = TarFile();
  ts.filename = file.name;
  ts.fileSize = file.size;
  ts.mode = file.mode;
  ts.ownerId = file.ownerId;
  ts.groupId = file.groupId;
  ts.lastModTime = file.lastModTime;
  ts.content = file.content;
  ts.write(_outputStream);
}