Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
class method
File.readlink
(::path link_name) -> ::String
File.readlink(link_path) → string
file.c
View on GitHub ↗
static VALUE
rb_file_s_readlink(VALUE klass, VALUE path)
{
return rb_readlink(path, rb_filesystem_encoding());
}
Returns the string path to the entry referenced by the symbolic link at link_path:
Example
filepath = 'doc/maintainers.md' linkpath = '/tmp/link' File.symlink(filepath, linkpath) File.readlink(linkpath) # => "doc/maintainers.md" File.delete(linkpath) # Clean up.
Raises Errno::EINVAL if the entry referenced by link_path is not a symbolic link.
See also
.readable_real?
.realdirpath
.readable?
.realpath
also in
4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0