On Wed, 19 Nov 2008 15:49:16 +0000, Tom Anderson
<> wrote, quoted or indirectly quoted someone who
said :
>> There is a open source utility called md5.It will return the checksum
>> based on the file content.
>
>It involves at least as much IO as comparing the files directly (it will
>do more when they differ, because it doesn't fail fast), and isn't
>guaranteed to work - two different files can have the same MD5 hash. It's
>no better.
You can fail fast by comparing file length. If they don't match you
are done. You don't even need to read either file for that.
For the usual case, I would just do a single unbuffered byte read of
each file, then a loop to compare corresponding indexes. For long
files, you must compare in long chunks, reusing the same buffers to
avoid swamping the GC.
--
Roedy Green Canadian Mind Products
http://mindprod.com
Your old road is
Rapidly agin'.
Please get out of the new one
If you can't lend your hand
For the times they are a-changin'.