[LC++]Copying files and deleting directories

Chris Vine chris at cvine.freeserve.co.uk
Sat Sep 11 06:20:02 UTC 2004


On Wednesday 08 September 2004 18:27, Jan Pfeifer wrote:
> there is no system call or standard c library function to copy files. To
> avoid researching about ideal buffer sizes and whatever other details
> that may be involved in copying files -- the source for the gnu cp
> program is quite big --, I'd recommend using:

There is however a standard C++ way of doing it.

If you have opened a ifstream object filein and a ofstream object fileout it 
simply becomes:

fileout << filein.rdbuf();

It is also fast: it provides a direct filebuffer to filebuffer transfer.

Chris.




More information about the tuxCPProgramming mailing list