CFile::formatFileSize PHP Method

formatFileSize() private method

Converts file size in bytes into human readable format (i.e. '70.4 KB')
private formatFileSize ( integer $bytes, string $format = '0.00' ) : string
$bytes integer Filesystem object size in bytes
$format string Number format (see {@link CNumberFormatter})
return string Filesystem object size in human readable format
    private function formatFileSize($bytes, $format = '0.00')
    {
        $units = array('B', 'kB', 'MB', 'GB', 'TB', 'PB');
        $bytes = max($bytes, 0);
        $expo = floor(($bytes ? log($bytes) : 0) / log(1024));
        $expo = min($expo, count($units) - 1);
        $bytes /= pow(1024, $expo);
        return $this->formatNumber($bytes, $format) . ' ' . $units[$expo];
    }