This built-in predicate calculates an MD5 digest value for the specified file. An MD5 digest value is a unique number which can be used to check if a file has been changed or not. If a file has been changed then the calculated MD5 digest is different from the original MD5 digest.
An MD5 digest value is an atom of 16 characters enclosed by single quotes. The single quotes are added to make sure that the calculated value is always a valid atom according to the syntax rules of Prolog.
see also: app_dir/1 atom_reset_md5/0 atom_update_md5/1 atom_final_md5/1 base64_decode_file/2 base64_encode_file/2 compress_file/2 copy_file/2 current_dir/1 decompress_file/1 decompress_file/2 decrypt_file/3 delete_file/1 encrypt_file/3 exists_dir/1 exists_file/1 info_file/2 make_dir/1 next_file/2 next_file/3 next_dir/2 remove_dir/1 rename_file/2 set_current_dir/1 split_fn/2 unlink_file/1 wipe_file/1
| Examples | |
| md5_file('c:\\temp\\doc.txt', A). | a MD5 digest value is calculated for the file
'c:\\temp\\doc.txt', a possible MD5 digest value can be: A = 'VõM¾ý½¢ÙV&i&ì' |
| md5_file('c:\\temp\\doc.txt', 'VõM¾ý½¢ÙV&i&ì'). | the predicate succeeds, the calculated MD5 digest value and the value of the second parameter are identical |
| md5_file('c:\\temp\\doc.txt', 'aõM¾ý½¢ÙV&i&ì'). | the predicate fails, the calculated MD5 digest value and the value of the second parameter are not identical |
| Exceptions | |
| The file argument is an empty variable | an instantiation_error exception is thrown |
| The file argument Arg is not an atom enclosed by single or double quotes | a type_error(atom_singlequotes, Arg) exception is thrown |
| The File to calculate the MD5 digest for cannot be opened for reading | an existence_error(file, File) exception is thrown |