D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
self
/
root
/
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
FileUtils
/
Filename :
cp-i.ri
back
Copy
U:RDoc::AnyMethod[iI"cp:ETI"FileUtils#cp;TF:privateo:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"Copies files.;To:RDoc::Markup::BlankLine o; ; [I":Arguments +src+ (a single path or an array of paths) ;TI" and +dest+ (a single path) ;TI"Kshould be {interpretable as paths}[rdoc-ref:FileUtils@Path+Arguments].;T@o; ; [I"OIf +src+ is the path to a file and +dest+ is not the path to a directory, ;TI"copies +src+ to +dest+:;T@o:RDoc::Markup::Verbatim; [ I"!FileUtils.touch('src0.txt') ;TI")File.exist?('dest0.txt') # => false ;TI"+FileUtils.cp('src0.txt', 'dest0.txt') ;TI"(File.file?('dest0.txt') # => true ;T:@format0o; ; [I"KIf +src+ is the path to a file and +dest+ is the path to a directory, ;TI"'copies +src+ to <tt>dest/src</tt>:;T@o;; [ I"!FileUtils.touch('src1.txt') ;TI"FileUtils.mkdir('dest1') ;TI"'FileUtils.cp('src1.txt', 'dest1') ;TI",File.file?('dest1/src1.txt') # => true ;T; 0o; ; [I"SIf +src+ is an array of paths to files and +dest+ is the path to a directory, ;TI"&copies from each +src+ to +dest+:;T@o;; [I"/src_file_paths = ['src2.txt', 'src2.dat'] ;TI"%FileUtils.touch(src_file_paths) ;TI"FileUtils.mkdir('dest2') ;TI"+FileUtils.cp(src_file_paths, 'dest2') ;TI",File.file?('dest2/src2.txt') # => true ;TI",File.file?('dest2/src2.dat') # => true ;T; 0o; ; [I"Keyword arguments:;T@o:RDoc::Markup::List: @type:BULLET:@items[o:RDoc::Markup::ListItem:@label0; [o; ; [I"4<tt>preserve: true</tt> - preserves file times.;To;;0; [o; ; [I"/<tt>noop: true</tt> - does not copy files.;To;;0; [o; ; [I";<tt>verbose: true</tt> - prints an equivalent command:;T@o;; [I"FFileUtils.cp('src0.txt', 'dest0.txt', noop: true, verbose: true) ;TI"BFileUtils.cp('src1.txt', 'dest1', noop: true, verbose: true) ;TI"FFileUtils.cp(src_file_paths, 'dest2', noop: true, verbose: true) ;T; 0o; ; [I"Output:;T@o;; [I"cp src0.txt dest0.txt ;TI"cp src1.txt dest1 ;TI" cp src2.txt src2.dat dest2 ;T; 0o; ; [I"1Raises an exception if +src+ is a directory.;T@o; ; [I"@Related: {methods for copying}[rdoc-ref:FileUtils@Copying].;T: @fileI"lib/fileutils.rb;T:0@omit_headings_from_table_of_contents_below000[[I" copy;To;; [ ;@[;0I"8(src, dest, preserve: nil, noop: nil, verbose: nil);T@[FI"FileUtils;TcRDoc::NormalModule00