ReadUInt64 is used over ReadUChar because of a very large speed increase, presumably from fewer disk reads.
The return codes are the similar to fc.
-1: There was an unidentified error in the comparison process
0: files are identical
1: data mismatch
2a: couldn't find the first file
2b: couldn't find the second file
3: size mismatch; useful when copying across disks.
Code: Select all
BinaryCompare(File1,File2)
{
F1 := FileOpen(File1,"r") ;Opens the first file
If A_LastError = 0
{
F1.Close()
return "2a" ; couldn't find the first file
}
F2 := FileOpen(File2,"r") ;Opens the second file
If A_LastError = 0
{
F1.Close()
F2.Close()
return "2b" ; couldn't find the second file
}
If ( F1.length() != F2.length() ) ;Simple check to ensure it's worth the time to compare
{
F1.Close()
F2.Close()
return "3" ; size mismatch
}
Loop, % (F1.length() / 8) + 1 ;uses the file size to set the maximum loops
{
If ( F1.ReaduInt64() != F2.ReaduInt64() )
{
F1.Close()
F2.Close()
return "1" ; data mismatch
break
}
}
;
If F1.ateof != 0 ; all is well, you are the proud parent of twins!
{
F1.Close()
F2.Close()
return "0"
}
else ; something has gone horribly, horribly wrong and one of your twins is evil.... but which!?
{
F1.Close()
F2.Close()
return "-1"
}
}