Ross Paterson wrote:
I find the following generalization of copyFile useful. Perhaps it could be added to System.Directory.
{- |@'copyContents' old new@ copies the contents of /old/ to /new/, creating /new/ if it does not already exist.
Copying files and directories opens a huge can of worms, due to issues such as: 1. Should metadata (ownership, permissions, timestamps) be preserved? 2. What if the destination exists? What if the destination is a symlink? Should the destination be opened for writing, or should it be deleted and a new file created? 3. If the source is a symlink (or if the source tree contains symlinks), should the symlink be copied or should it be dereferenced and the contents copied to a new file? There is no one "correct" way to copy a file, and the situation is even more involved for directory trees (e.g. if parts of the destination hierarchy already exist). -- Glynn Clements <glynn@gclements.plus.com>