Skip to content
class method

FileUtils.copy_file

(::FileUtils::path src, ::FileUtils::path dest, ?::boolish preserve, ?::boolish dereference) -> void
copy_file(src, dest, preserve = false, dereference = true)

Copies file from src to dest, which should not be directories.

Arguments src and dest should be interpretable as paths.

Examples:

Example
FileUtils.touch('src0.txt')
FileUtils.copy_file('src0.txt', 'dest0.txt')
File.file?('dest0.txt') # => true

Optional arguments:

  • dereference - if src is a symbolic link, follows the link (true by default).

  • preserve - preserves file times (false by default).

  • remove_destination - removes dest before copying files (false by default).

Related: methods for copying.

See also #copy_file .copy_entry .copy_stream .copy also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0