proposed addition to System.Directory

Glynn Clements glynn at
Wed Jan 12 09:05:31 EST 2005

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 at>

More information about the Libraries mailing list