Move get_file_size() helper function to helpers.php.

This commit is contained in:
Franz Liedke
2012-07-07 02:13:44 +02:00
parent 94e9106b76
commit 6b5cccc15f
2 changed files with 14 additions and 14 deletions

View File

@@ -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];
}