[Gambas-user] Binary compare of files?
Doriano Blengino
doriano.blengino at ...1909...
Fri Oct 17 08:18:20 CEST 2008
Kari Laine ha scritto:
> Hi All,
>
> could someone please give me a hint how compare two files for binary
> equality?
> I am doing it now int by int basis and it is taking years. I would like to
> read big chunks of both files and compare.
> Also I am thinking a possibility to read whole files in memory at once and
> then compare.
>
>
I think you can read chunks of 256, 512, 1024 or more:
do
read #file1, s1, -256
read #file2, s2, -256
if s1<>s2 then
files_are_different()
break
endif
while len(s1)=256
Note the "-256" which reads up to 256 bytes, or up to the end of file.
Ideally, the higher the number the quicker should be, but some
experiment should be done. May be 8192, 16384 or so could do well.
I didn't try this, however.
Regards,
Doriano
More information about the User
mailing list