[LC++]file copying

Paul Gearon pag at pisoftware.com
Thu Jan 29 13:24:01 UTC 2004


Kar G Lim wrote:
> Anyone can see the source:
> 
> http://www.gnu.org/software/fileutils/fileutils.html
> 
> just get the source
> 
> From: Jan Pfeifer <pfjan at yahoo.com.br>
 >
>>ps.: i did some measuring with the code, and it still takes 1.5 the time
>>/bin/cp takes to copy. Anyone knows how /bin/cp does this faster ? I
>>would guess it somehow manages to avoid a buffer copying, maybe using
>>memory mapped files ...

This code demonstrates why I hate reading code for standard GNU 
utilities.  There are so many options that finding what you want is a 
time-consuming pain!

But after several minutes of trawling I found the code in question... 
and it comes down to looping on plain-old, vanilla read/write calls. 
There is one trick to increase speed - it calculates how large its 
buffer should be before it starts.

Paul



More information about the tuxCPProgramming mailing list