[Gambas-user] Binary compare of files?
Stefano Palmeri
rospolosco at ...152...
Fri Oct 17 10:03:45 CEST 2008
Il venerdì 17 ottobre 2008 08:18:20 Doriano Blengino ha scritto:
> 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
>
If you only want to know if two files are identical,
you could use md5sum.
Ciao,
Stefano
>
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's
> challenge Build the coolest Linux based applications with Moblin SDK & win
> great prizes Grand prize is a trip for two to an Open Source event anywhere
> in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
More information about the User
mailing list