resolveSymLink function

String resolveSymLink(
  1. String pathToLink
)

Resolves the a symbolic link pathToLink to the ultimate target path.

The return path will be canonicalized.

e.g.

resolveSymLink('/usr/bin/dart) == '/usr/lib/bin/dart'

throws a FileSystemException if the target path does not exist.

Implementation

String resolveSymLink(String pathToLink) {
  final normalised = canonicalize(pathToLink);

  String resolved;
  if (isDirectory(normalised)) {
    resolved = Directory(normalised).resolveSymbolicLinksSync();
  } else {
    resolved = canonicalize(File(normalised).resolveSymbolicLinksSync());
  }

  verbose(() => 'resolveSymLink $pathToLink resolved: $resolved');
  return resolved;
}