@@ -475,7 +475,8 @@ def ln(src, dest, force: nil, noop: nil, verbose: nil)
475475 #
476476 # Keyword arguments:
477477 #
478- # - <tt>dereference_root: false</tt> - does not follow soft links.
478+ # - <tt>dereference_root: false</tt> - if +src+ is a symbolic link,
479+ # does not dereference it.
479480 # - <tt>noop: true</tt> - does not create links.
480481 # - <tt>remove_destination: true</tt> - removes +dest+ before creating links.
481482 # - <tt>verbose: true</tt> - prints an equivalent command:
@@ -488,8 +489,8 @@ def ln(src, dest, force: nil, noop: nil, verbose: nil)
488489 # cp -lr tmp0 tmp1
489490 # cp -lr tmp0/tmp3/t2.txt tmp0/tmp3/t3.txt tmp1
490491 #
491- # Raises an exception if +dest+ is the path to an existing file
492- # and keyword argument + remove_destination+ is not +true+ .
492+ # Raises an exception if +dest+ is the path to an existing file or directory
493+ # and keyword argument <tt> remove_destination: true</tt> is not given .
493494 #
494495 def cp_lr ( src , dest , noop : nil , verbose : nil ,
495496 dereference_root : true , remove_destination : false )
@@ -578,29 +579,48 @@ def ln_s(src, dest, force: nil, noop: nil, verbose: nil)
578579 alias symlink ln_s
579580 module_function :symlink
580581
581- #
582- # :call-seq:
583- # FileUtils.ln_sf(*args)
584- #
585- # Same as
586- #
587- # FileUtils.ln_s(*args, force: true)
582+ # Like FileUtils.ln_s, but always with keyword argument <tt>force: true</tt> given.
588583 #
589584 def ln_sf ( src , dest , noop : nil , verbose : nil )
590585 ln_s src , dest , force : true , noop : noop , verbose : verbose
591586 end
592587 module_function :ln_sf
593588
589+ # Creates {hard links}[https://en.wikipedia.org/wiki/Hard_link]; returns +nil+.
594590 #
595- # Hard links a file system entry +src+ to +dest+.
596- # If +src+ is a directory, this method links its contents recursively.
591+ # If +src+ is the path to a file and +dest+ does not exist,
592+ # creates a hard link at +dest+ pointing to +src+:
597593 #
598- # Both of +src+ and +dest+ must be a path name.
599- # +src+ must exist, +dest+ must not exist.
594+ # FileUtils.touch('src0.txt')
595+ # File.exist?('dest0.txt') # => false
596+ # FileUtils.link_entry('src0.txt', 'dest0.txt')
597+ # File.exist?('dest0.txt') # => true
600598 #
601- # If +dereference_root+ is true, this method dereferences the tree root.
599+ # If +src+ is the path to a directory and +dest+ does not exist,
600+ # recursively creates hard links at +dest+ pointing to paths in +src+:
601+ #
602+ # FileUtils.mkdir_p(['src1/dir0', 'src1/dir1'])
603+ # src_file_paths = [
604+ # 'src1/dir0/t0.txt',
605+ # 'src1/dir0/t1.txt',
606+ # 'src1/dir1/t2.txt',
607+ # 'src1/dir1/t3.txt',
608+ # ]
609+ # FileUtils.touch(src_file_paths)
610+ # File.exist?('dest1')
611+ # FileUtils.link_entry('src1', 'dest1')
612+ # File.exist?('dest1/dir0/t0.txt') # => true
613+ # File.exist?('dest1/dir0/t1.txt') # => true
614+ # File.exist?('dest1/dir1/t2.txt') # => true
615+ # File.exist?('dest1/dir1/t3.txt') # => true
602616 #
603- # If +remove_destination+ is true, this method removes each destination file before copy.
617+ # Keyword arguments:
618+ #
619+ # - <tt>dereference_root: true</tt> - dereferences +src+ if it is a symbolic link.
620+ # - <tt>remove_destination: true</tt> - removes +dest+ before creating links.
621+ #
622+ # Raises an exception if +dest+ is the path to an existing file or directory
623+ # and keyword argument <tt>remove_destination: true</tt> is not given.
604624 #
605625 def link_entry ( src , dest , dereference_root = false , remove_destination = false )
606626 Entry_ . new ( src , nil , dereference_root ) . traverse do |ent |
0 commit comments