function file_feeds_file_compare in Feeds 7.2
Compares two files to determine if they are the same.
Parameters
string $file1: The path to the first file to compare.
string $file2: The path to the second file to compare.
Return value
bool TRUE if the files are the same. FALSE otherwise.
5 calls to file_feeds_file_compare()
- FeedsMapperFileTestCase::testFileExistsRenameIfDifferent in tests/
feeds_mapper_file.test - Test mapping of local resources with the file exists "Rename if different" setting.
- FeedsMapperFileTestCase::testFileExistsReplace in tests/
feeds_mapper_file.test - Test mapping of local resources with the file exists "Replace" setting.
- FeedsMapperFileTestCase::testFileExistsReplaceIfDifferent in tests/
feeds_mapper_file.test - Test mapping of local resources with the file exists "Replace if different" setting.
- FeedsMapperFileTestCase::testFileExistsSkip in tests/
feeds_mapper_file.test - Test mapping of local resources with the file exists "Skip existig" setting.
- file_feeds_set_target in mappers/
file.inc - Callback for mapping file fields.
File
- mappers/
file.inc, line 272 - On behalf implementation of Feeds mapping API for file.module and image.module.
Code
function file_feeds_file_compare($file1, $file2) {
// If the file size is different then assume they are different files.
// However, remote files may return FALSE from filesize() so only compare
// file sizes if both values are not empty.
$filesize1 = filesize($file1);
$filesize2 = filesize($file2);
if ($filesize1 !== FALSE && $filesize2 !== FALSE && $filesize1 !== $filesize2) {
return FALSE;
}
// File sizes are the same so check md5 hash of files.
if (md5_file($file1) != md5_file($file2)) {
return FALSE;
}
return TRUE;
}