[LC++]file copying

Jan Pfeifer pfjan at yahoo.com.br
Fri Jan 30 00:01:04 UTC 2004


> 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!

i totally agree with you. I had to go through cp.c, copy.c,
full_write.c/h safe_read.c/h to find the code, hidden by some #defines
... ugh.

> 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.

i thought about this, but then in one test i did, i copied 10000 times a
small file that would fit entirely in the buffer I allocated and it was
still 1.5 times slower than /bin/cp ...

do you understand in this case why the difference ?

ops, i noticed also that i forgot to handle the EINTR error ... that's
why i hate the too low-level C interface. Nice that Carlo pointed out a
good C++ solution.

:)

Jan


> 
> Paul
> _______________________________________________
> This is the Linux C++ Programming List
> : http://lists.linux.org.au/listinfo/tuxcpprogramming List
> 




More information about the tuxCPProgramming mailing list