We need to compare the contents of two (or more) text files to determine if we need to create a backup. If they differ we create a new backup.
I currently use the CRC value of each file to check for differences but I was wondering if there is a more efficient or elegant way of detecting differences between to files.
//Use madZIP to calculate the CRC fior this file
GetUncompressedFileInfo(Filename_1, Size_1, NewCRC);
//Use madZIP to calculate the CRC fior this file
GetUncompressedFileInfo(Filename_2, Size_2, OldCRC);
//if ThisFileHash = ExistingFileHash then
if (OldCRC <> NewCRC) then
CreateABackup;
Regards, Pieter.
CRC is not a safe method to detect file changes - cryptographic hashes (like MD5 or SHA1) are much better.
Another approach (like the one used by build systems) is to compare file dates. If the file is newer than backup, a new backup is needed.
CRC is probably more accurate, and pretty efficient. However do you need to check the contents?
I'm assuming you're checking the CRC to see if a modification has been made and re-backup the updated file. In which case FileAge() would do just fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With