Well i have one file on my server and other on my computer. What i want to do is a simple updater that checks if the file of my computer is equal to the one uploaded in the server. (If it's equal then it hasn't been updated, if it's not equal then download)
I'm using QNetworkAccessManager to download files. Any idea?
In that case it is recommended to make use of the cmp command. The cmp command is a Linux utility command that is used to compare two files.
You need to use the grep command. The grep command or egrep command searches the given input FILEs for lines containing a match or a text string.
You can generate a checksum from a file in the following way:
QCryptographicHash hash( QCryptographicHash::Sha1 );
QFile file( fileName );
if ( file.open( QIODevice::ReadOnly ) ) {
hash.addData( file.readAll() );
} else {
// Handle "cannot open file" error
}
// Retrieve the SHA1 signature of the file
QByteArray sig = hash.result();
Do this for both files (while somehow getting the signature from one machine to the other) and compare the results.
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