get_checksum()

Description

Return a checksum for the given file path.

Parameters

ColumnTypeDefaultDescription
$path string Path to file
$forcefull bool false Force use of whole file and ignore $file_checksums_50k setting

Return

string|false Return the checksum value, false otherwise.

Location

include/file_functions.php lines 85 to 102

Definition

 
function get_checksum($path$forcefull false)
{
    
debug("get_checksum( \$path = {$path} );");
    global 
$file_checksums_50k;
    if (!
is_readable($path)) {
        return 
false;
    }

    
# Generate the ID
    
if ($file_checksums_50k && !$forcefull) {
        
# Fetch the string used to generate the unique ID
        
$use filesize_unlimited($path) . "_" file_get_contents($pathfalsenull050000);
        
$checksum md5($use);
    } else {
        
$checksum md5_file($path);
    }
    return 
$checksum;
}

This article was last updated 6th April 2025 21:35 Europe/London time based on the source file dated 4th April 2025 18:05 Europe/London time.