deleteIfLink function

void deleteIfLink(
  1. String file
)

Deletes file if it's a symlink.

The File class overwrites the symlink targets when writing to a file, which is never what we want, so this delete the symlink first if necessary.

Implementation

void deleteIfLink(String file) {
  if (!linkExists(file)) return;
  Link(file).deleteSync();
}