mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-06 18:21:39 +09:00
Improve FileHandler::returnBytes() to handle a wider range of sizes
This commit is contained in:
parent
f313e693c4
commit
d34ef5901f
1 changed files with 3 additions and 0 deletions
|
|
@ -426,11 +426,14 @@ class FileHandler
|
||||||
*/
|
*/
|
||||||
public static function returnBytes($val)
|
public static function returnBytes($val)
|
||||||
{
|
{
|
||||||
|
$val = preg_replace('/[^0-9\.PTGMK]/', '', $val);
|
||||||
$unit = strtoupper(substr($val, -1));
|
$unit = strtoupper(substr($val, -1));
|
||||||
$val = (float)$val;
|
$val = (float)$val;
|
||||||
|
|
||||||
switch ($unit)
|
switch ($unit)
|
||||||
{
|
{
|
||||||
|
case 'P': $val *= 1024;
|
||||||
|
case 'T': $val *= 1024;
|
||||||
case 'G': $val *= 1024;
|
case 'G': $val *= 1024;
|
||||||
case 'M': $val *= 1024;
|
case 'M': $val *= 1024;
|
||||||
case 'K': $val *= 1024;
|
case 'K': $val *= 1024;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue