End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
File::Stat#symlink?
stat.symlink? → true or false
file.c
View on GitHub ↗
static VALUE
rb_stat_l(VALUE obj)
{
#ifdef S_ISLNK
if (S_ISLNK(get_stat(obj)->st_mode)) return Qtrue;
#endif
return Qfalse;
}
Returns true if stat is a symbolic link, false if it isn’t or if the operating system doesn’t support this feature. As File::stat automatically follows symbolic links, symlink? will always be false for an object returned by File::stat.
Example
File.symlink("testfile", "alink") #=> 0 File.stat("alink").symlink? #=> false File.lstat("alink").symlink? #=> true