isLink function

bool isLink(
  1. String path
)

Check if a path points to a symbolic link.

This function checks the path without following links to determine if it's a symbolic link itself.

Parameters:

  • path: The path to check

Returns true if the path is a symbolic link, false otherwise.

Example:

if (isLink('/path/to/symlink')) {
  print('It\'s a symbolic link');
}

Implementation

bool isLink(String path) {
  final fromType = FileSystemEntity.typeSync(path, followLinks: false);
  return fromType == FileSystemEntityType.link;
}