Function: file-symlink-p

file-symlink-p is a function defined in fileio.c.

Signature

(file-symlink-p FILENAME)

Documentation

Return non-nil if file FILENAME is the name of a symbolic link.

The value is the link target, as a string. Return nil if FILENAME does not exist or is not a symbolic link, of there was trouble determining whether the file is a symbolic link.

This function does not check whether the link target exists.

Other relevant functions are documented in the file group.

Probably introduced at or before Emacs version 26.1.

Shortdoc

;; file
(file-symlink-p "/tmp/foo")
    e.g. => t

Source Code

// Defined in /usr/src/emacs/src/fileio.c
{
  Lisp_Object handler;

  CHECK_STRING (filename);
  filename = Fexpand_file_name (filename, Qnil);

  /* If the file name has special constructs in it,
     call the corresponding file name handler.  */
  handler = Ffind_file_name_handler (filename, Qfile_symlink_p);
  if (!NILP (handler))
    return call2 (handler, Qfile_symlink_p, filename);

  return emacs_readlinkat (AT_FDCWD, SSDATA (ENCODE_FILE (filename)));
}