[LC++]Copying files and deleting directories
Jack Lloyd
lloyd at acm.jhu.edu
Thu Sep 9 04:48:05 UTC 2004
On Wed, Sep 08, 2004 at 02:27:30PM -0300, 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:
>
> /* see "system" c function: man 3 system */
> system( "/bin/cp source_file target_file" );
>
> unfortunately this solution is probably not portable outside the unix
> environment. But then, this is a linux-c++ list :)
>
> best luck,
>
> jan
a) This is pretty slow.
b) Depending on the application, you've got to make sure your filenames' don't
contain `rm -rf $HOME` or similiar, as the shell will happily execute that.
-Jack
More information about the tuxCPProgramming
mailing list