Skip to content

Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →

instance method

Pathname#make_link

(::String | ::Pathname | ::_ToStr old) -> ::Integer
make_link(path) → 0

Not available on some systems.

Creates a new entry at the path in self for the existing entry at path using a hard link:

Example
File.write('doc/t.tmp', 'foo')
Pathname('lib/u.tmp').make_link('doc/t.tmp')
File.read('lib/u.tmp') # => "foo"
File.write('lib/u.tmp', 'bar')
File.read('doc/t.tmp') # => "bar"
File.delete('doc/t.tmp')
File.read('lib/u.tmp') # => "bar"
File.delete('lib/u.tmp')

Raises an exception if the entry at the path in self exists.

See also #lutime #make_symlink #lstat #mkdir also in 4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0