summaryrefslogtreecommitdiff
path: root/lib/fileutils.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/fileutils.rb')
-rw-r--r--lib/fileutils.rb16
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/fileutils.rb b/lib/fileutils.rb
index 57ab0cf77ae..7bc852ea91f 100644
--- a/lib/fileutils.rb
+++ b/lib/fileutils.rb
@@ -526,12 +526,14 @@ public
# If +remove_destination+ is true, this method removes each destination file before copy.
#
def copy_entry(src, dest, preserve = false, dereference_root = false, remove_destination = false)
- Entry_.new(src, nil, dereference_root).traverse do |ent|
+ Entry_.new(src, nil, dereference_root).wrap_traverse(proc do |ent|
destent = Entry_.new(dest, ent.rel, false)
File.unlink destent.path if remove_destination && File.file?(destent.path)
ent.copy destent.path
+ end, proc do |ent|
+ destent = Entry_.new(dest, ent.rel, false)
ent.copy_metadata destent.path if preserve
- end
+ end)
end
define_command(:copy_entry)
@@ -1540,6 +1542,16 @@ private
yield self
end
+ def wrap_traverse(pre, post)
+ pre.call self
+ if directory?
+ entries.each do |ent|
+ ent.wrap_traverse pre, post
+ end
+ end
+ post.call self
+ end
+
private
$fileutils_rb_have_lchmod = nil