Method: FileUtils#cp
- Defined in:
- lib/fileutils.rb
#cp(src, dest, options = {}) ⇒ Object Also known as: copy
Options: preserve noop verbose
Copies a file content src
to dest
. If dest
is a directory, copies src
to dest/src
.
If src
is a list of files, then dest
must be a directory.
FileUtils.cp 'eval.c', 'eval.c.org'
FileUtils.cp %w(cgi.rb complex.rb date.rb), '/usr/lib/ruby/1.6'
FileUtils.cp %w(cgi.rb complex.rb date.rb), '/usr/lib/ruby/1.6', :verbose => true
FileUtils.cp 'symlink', 'dest' # copy content, "dest" is not a symlink
387 388 389 390 391 392 393 394 |
# File 'lib/fileutils.rb', line 387 def cp(src, dest, = {}) , OPT_TABLE['cp'] "cp#{[:preserve] ? ' -p' : ''} #{[src,dest].flatten.join ' '}" if [:verbose] return if [:noop] fu_each_src_dest(src, dest) do |s, d| copy_file s, d, [:preserve] end end |