[LC++]file copying

Carlo Wood carlo at alinoe.com
Wed Jan 28 22:13:02 UTC 2004


http://gcc.gnu.org/onlinedocs/libstdc++/27_io/howto.html#1
and
http://gcc.gnu.org/onlinedocs/libstdc++/27_io/howto.html#8

On Wed, Jan 28, 2004 at 02:57:33AM +0000, larry wrote:
> I have a problem  related to the speed of copying files in C++ on linux.  I need to automate a process to copy files from one directory to another for media management.  Anyway, the following code is what I have been using and it is not nearly fast enough.  The entire focus of this application is speed.  In fact in Windows, I am getting at least 5 times the speed from a VB app that I am using.  I know I must be doing something wrong.  I am compiling on a one processor machine and moving it to the test equipment which has four processors and 4 gigs or RAM.  I wonder should I compile it there to see if it runs better or is there a better method for copying files from one directory to another.  The file system is Reiserfs on a gentoo installation.  The machine that I am compiling on is ext3 on Redhat.
> 
> IPFile = fopen("/home/this.jpg","r");
> OPFile = fopen("/mediafiles/this.jpg","w");
> while ((c = fgetc(IPFile)) != EOF)
> {
>     fputc(c, OPFile);
> }
> fclose(IPFile);
> fclose(OPFile);
> 
> Anyway, I am at a loss.  There has to be a better method than this.  Thanks.
> 
> ---
> Larry Lines

-- 
Carlo Wood <carlo at alinoe.com>



More information about the tuxCPProgramming mailing list