mirror of
https://git.code.sf.net/p/seeddms/code
synced 2024-11-26 23:42:11 +00:00
fix parsing of file size
This commit is contained in:
parent
a4ccfe1a7d
commit
f817fc4489
|
@ -93,13 +93,12 @@ class SeedDMS_Core_File {
|
|||
* @return bool|int
|
||||
*/
|
||||
static function parse_filesize($str) { /* {{{ */
|
||||
preg_replace('/\s\s+/', ' ', $str);
|
||||
if(strtoupper(substr($str, -1)) == 'B') {
|
||||
$value = (int) substr($str, 0, -2);
|
||||
$unit = substr($str, -2, 1);
|
||||
} else {
|
||||
preg_replace('/\s\s+/', '', $str);
|
||||
if(in_array(strtoupper(substr($str, -1)), array('B','K','M','G'))) {
|
||||
$value = (int) substr($str, 0, -1);
|
||||
$unit = substr($str, -1);
|
||||
$unit = substr($str, -1, 1);
|
||||
} else {
|
||||
return (int) $str;
|
||||
}
|
||||
switch(strtoupper($unit)) {
|
||||
case 'G':
|
||||
|
|
Loading…
Reference in New Issue
Block a user