Move get_file_size() helper function to helpers.php.
This commit is contained in:
@@ -580,4 +580,16 @@ function get_cli_option($option, $default = null)
|
||||
}
|
||||
|
||||
return value($default);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the human-readable file size (with proper units).
|
||||
*
|
||||
* @param int $size
|
||||
* @return string
|
||||
*/
|
||||
function get_file_size($size)
|
||||
{
|
||||
$units = array('Bytes', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB');
|
||||
return @round($size / pow(1024, ($i = floor(log($size, 1024)))), 2).' '.$units[$i];
|
||||
}
|
||||
Reference in New Issue
Block a user