End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
class method
FileUtils.cp_lr
cp_lr(src, dest, noop: nil, verbose: nil, dereference_root: true, remove_destination: false)
lib/fileutils.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.0.5/lib/fileutils.rb, line 342
def cp_lr(src, dest, noop: nil, verbose: nil,
dereference_root: true, remove_destination: false)
fu_output_message "cp -lr#{remove_destination ? ' --remove-destination' : ''} #{[src,dest].flatten.join ' '}" if verbose
return if noop
fu_each_src_dest(src, dest) do |s, d|
link_entry s, d, dereference_root, remove_destination
end
end
Hard link src to dest. If src is a directory, this method links all its contents recursively. If dest is a directory, links src to dest/src.
src can be a list of files.
If dereference_root is true, this method dereference tree root.
If remove_destination is true, this method removes each destination file before copy.
Example
FileUtils.rm_r site_ruby + '/mylib', force: true FileUtils.cp_lr 'lib/', site_ruby + '/mylib' # Examples of linking several files to target directory. FileUtils.cp_lr %w(mail.rb field.rb debug/), site_ruby + '/tmail' FileUtils.cp_lr Dir.glob('*.rb'), '/home/aamine/lib/ruby', noop: true, verbose: true # If you want to link all contents of a directory instead of the # directory itself, c.f. src/x -> dest/x, src/y -> dest/y, # use the following code. FileUtils.cp_lr 'src/.', 'dest' # cp_lr('src', 'dest') makes dest/src, but this doesn't.