Bug #7246
closedFileUtils.cp_r does not preserve attributes of directories
Description
(({FileUtils.cp_r})) does not preserve the file attributes of directories because the attributes are set before copying to the directory.
The following monkey patch fixes this behaviour. However the monkey patch relies on the contents of the source directory not changing during the copy operation.
(({require 'fileutils'
def copy_entry(src, dest, preserve = false, dereference_root = false, remove_destination = false)
Entry_.new(src, nil, dereference_root).traverse 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
Entry_.new(src, nil, dereference_root).postorder_traverse do |ent|
destent = Entry_.new(dest, ent.rel, false)
ent.copy_metadata destent.path if preserve
end
end
module_function :copy_entry
end}))