handle special case size=1 in format_filesize()

This commit is contained in:
Uwe Steinmann 2021-10-04 20:24:51 +02:00
parent 7bac4e730e
commit 790eef7e84

View File

@ -84,6 +84,7 @@ class SeedDMS_Core_File {
*/ */
static function format_filesize($size, $sizes = array('Bytes', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB')) { /* {{{ */ static function format_filesize($size, $sizes = array('Bytes', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB')) { /* {{{ */
if ($size == 0) return('0 Bytes'); if ($size == 0) return('0 Bytes');
if ($size == 1) return('1 Byte');
/** @noinspection PhpIllegalArrayKeyTypeInspection */ /** @noinspection PhpIllegalArrayKeyTypeInspection */
return (round($size/pow(1024, ($i = floor(log($size, 1024)))), 2) . ' ' . $sizes[$i]); return (round($size/pow(1024, ($i = floor(log($size, 1024)))), 2) . ' ' . $sizes[$i]);
} /* }}} */ } /* }}} */