writeBytesSync static method

void writeBytesSync(
  1. File target,
  2. List<int> bytes
)

Implementation

static void writeBytesSync(File target, List<int> bytes) {
  target.parent.createSync(recursive: true);
  final temporary = File(
    '${target.path}.tmp-${pid}-${DateTime.now().microsecondsSinceEpoch}',
  );
  try {
    temporary.writeAsBytesSync(bytes, flush: true);
    temporary.renameSync(target.path);
  } finally {
    if (temporary.existsSync()) temporary.deleteSync();
  }
}