News:

Function Finder  Find all the functions within source code files

Main Menu

Compare Files

Started by kevin, April 09, 2011, 10:55:52 AM

Previous topic - Next topic

kevin

  Compare Files

 Here's a little function that will compare if two files are the same at binary level.  All you need to do is supply it with the absolute locations of both files and it'll brute force the comparison.    It works by loading the entire contents of both files into a pair and strings and then doing an equality test (=)  upon them..

PlayBASIC Code: [Select]
   path$="C:\Location Of The Files You Want to Compare\"

file1$ =path$+"filename1.txt"
file2$ =path$+"filename1.txt"

result=CompareFiles(File1$,File2$)

print Result
Sync
waitkey



function CompareFiles(file1$,File2$)
Result=false
if lower$(File1$)=Lower$(file2$) then exitfunction true
if FIleexist(file1$) and FIleexist(file2$)

size1=filesize(file1$)
size2=filesize(file2$)
if Size1=Size2

// load file 1 intoi a string
f1=readnewfile(file1$)
FileString1$=readchr$(f1,size1)
closefile f1

f2=readnewfile(file2$)
FileString2$=readchr$(f2,size2)
closefile f2

// compare them
result=FileString1$=FileString2$

endif
endif
EndFunction Result