def copy_entry(src, dst, preserve=false, remove_destination=false)
case File.ftype(src)
when 'fifo', 'characterSpecial', 'blockSpecial', 'socket'
st = File.stat(src)
rc = mknod_w(dst, st.mode, st.dev)
raise SystemCallError.new("mknod error", FFI.errno) if rc == -1
when 'directory'
FileUtils.mkdir(dst) unless File.exists? dst
else
st = File.lstat(src)
known_entry = copied_entries[[st.dev, st.ino]]
if known_entry
FileUtils.ln(known_entry, dst)
else
FileUtils.copy_entry(src, dst, preserve, false,
remove_destination)
copied_entries[[st.dev, st.ino]] = dst
end
end
end