ID:257772
 
//  Title: Binary-Safe File Comparison
// Contributed by: Kuraudo S.

/*
There are some cases when you might want to test multiple files for
equality, and base it on their actual binary data rather than filenames.
You can achieve this via a couple of ExportText() calls.

The arguments to the CompareData() proc should be actual references
to the filedata (such as an /icon type), rather than filenames.
*/


proc
CompareData(file1, file2) // Returns 0 if file1 == file2
var/savefile
S = new
T = new
S["data"] << file1
T["data"] << file2

return ( S.ExportText() != T.ExportText() )

// /*
// Testing Code/Sample Implementation:

client/verb/Compare_Files()
var
f1 = input(src, "Select file 1:") as file
f2 = input(src, "Select file 2:") as file

if(CompareData(f1, f2))
src << "The files are not the same."
else
src << "The files are the same."

// */
I like you.