diff options
author | Burdette Lamar <BurdetteLamar@Yahoo.com> | 2022-05-25 17:08:14 -0500 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2022-05-26 07:08:26 +0900 |
commit | 012eb9b70d77bfd93208131e2ae83fc63840e3c3 (patch) | |
tree | d0f0694c7e0861039f29972c020110a8a3c10bc4 /lib/fileutils.rb | |
parent | d875445e8a8b073298e8b3db177d1a5e78c92893 (diff) |
[ruby/fileutils] [DOC] Enhanced RDoc for copy_entry (https://github.com/ruby/fileutils/pull/76)
https://github.com/ruby/fileutils/commit/27a3c376c7
Diffstat (limited to 'lib/fileutils.rb')
-rw-r--r-- | lib/fileutils.rb | 46 |
1 files changed, 34 insertions, 12 deletions
diff --git a/lib/fileutils.rb b/lib/fileutils.rb index 1769f194f4..940b035627 100644 --- a/lib/fileutils.rb +++ b/lib/fileutils.rb @@ -607,7 +607,7 @@ module FileUtils # 'src1/dir1/t3.txt', # ] # FileUtils.touch(src_file_paths) - # File.exist?('dest1') + # File.exist?('dest1') # => true # FileUtils.link_entry('src1', 'dest1') # File.exist?('dest1/dir0/t0.txt') # => true # File.exist?('dest1/dir0/t1.txt') # => true @@ -777,21 +777,43 @@ module FileUtils end module_function :cp_r + # Recursively copies files from +src+ to +dest+. # - # Copies a file system entry +src+ to +dest+. - # If +src+ is a directory, this method copies its contents recursively. - # This method preserves file types, c.f. symlink, directory... - # (FIFO, device files and etc. are not supported yet) - # - # Both of +src+ and +dest+ must be a path name. - # +src+ must exist, +dest+ must not exist. + # If +src+ is the path to a file, copies +src+ to +dest+: # - # If +preserve+ is true, this method preserves owner, group, and - # modified time. Permissions are copied regardless +preserve+. + # FileUtils.touch('src0.txt') + # File.exist?('dest0.txt') # => false + # FileUtils.copy_entry('src0.txt', 'dest0.txt') + # File.file?('dest0.txt') # => true + # + # If +src+ is a directory, recursively copies +src+ to +dest+: + # + # src1 + # |-- dir0 + # | |-- src0.txt + # | `-- src1.txt + # `-- dir1 + # |-- src2.txt + # `-- src3.txt + # FileUtils.copy_entry('src1', 'dest1') + # dest1 + # |-- dir0 + # | |-- src0.txt + # | `-- src1.txt + # `-- dir1 + # |-- src2.txt + # `-- src3.txt + # + # The recursive copying preserves file types for regular files, + # directories, and symbolic links; + # other file types (FIFO streams, device files, etc.) are not supported. # - # If +dereference_root+ is true, this method dereference tree root. + # Keyword arguments: # - # If +remove_destination+ is true, this method removes each destination file before copy. + # - <tt>dereference_root: true</tt> - if +src+ is a symbolic link, + # follows the link. + # - <tt>preserve</tt> - preserves file times. + # - <tt>remove_destination: true</tt> - removes +dest+ before copying files. # def copy_entry(src, dest, preserve = false, dereference_root = false, remove_destination = false) if dereference_root |