Method: FileUtils.copy_entry
- Defined in:
- lib/fileutils.rb
.copy_entry(src, dest, preserve = false, dereference_root = false, remove_destination = false) ⇒ Object
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 preserve is true, this method preserves owner, group, and modified time. Permissions are copied regardless preserve.
If dereference_root is true, this method dereference tree root.
If remove_destination is true, this method removes each destination file before copy.
489 490 491 492 493 494 495 496 497 498 499 500 501 502 |
# File 'lib/fileutils.rb', line 489 def copy_entry(src, dest, preserve = false, dereference_root = false, remove_destination = false) if dereference_root src = File.realpath(src) end Entry_.new(src, nil, false).wrap_traverse(proc do |ent| destent = Entry_.new(dest, ent.rel, false) File.unlink destent.path if remove_destination && (File.file?(destent.path) || File.symlink?(destent.path)) ent.copy destent.path end, proc do |ent| destent = Entry_.new(dest, ent.rel, false) ent. destent.path if preserve end) end |