copying a directory

Regan Heath regan at netmail.co.nz
Fri May 18 05:18:39 PDT 2007


jicman Wrote:
> 
> Greetings.
> 
> Is there a command for std.file to copy a directory?  I know that I can use
> mkdir and then copy all the files in there, but is there any place a copyDir
> command?
> 
> thanks.

Not that I recall but I've been away for a while so there might be.

I think ideally you want a function that uses the API to list files and for each file or directory it calls a callback (function/delegate) to perform the correct operation.

This general idea can be re-used for (optionally recursive) copy, delete, and any other change you might want to apply to a group of files and/or directories.

I wrote something just like this for my work on installers in the past.

You can also abstract out the source of the file listing, getting it from an FTP server, or database, or ... you end up with a library just like Matthew Wilson's one (I forget the name, sorry).

Regan Heath


More information about the Digitalmars-d-learn mailing list