mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-05-09 13:06:14 +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
|
* @return bool|int
|
||||||
*/
|
*/
|
||||||
static function parse_filesize($str) { /* {{{ */
|
static function parse_filesize($str) { /* {{{ */
|
||||||
preg_replace('/\s\s+/', ' ', $str);
|
preg_replace('/\s\s+/', '', $str);
|
||||||
if(strtoupper(substr($str, -1)) == 'B') {
|
if(in_array(strtoupper(substr($str, -1)), array('B','K','M','G'))) {
|
||||||
$value = (int) substr($str, 0, -2);
|
|
||||||
$unit = substr($str, -2, 1);
|
|
||||||
} else {
|
|
||||||
$value = (int) substr($str, 0, -1);
|
$value = (int) substr($str, 0, -1);
|
||||||
$unit = substr($str, -1);
|
$unit = substr($str, -1, 1);
|
||||||
|
} else {
|
||||||
|
return (int) $str;
|
||||||
}
|
}
|
||||||
switch(strtoupper($unit)) {
|
switch(strtoupper($unit)) {
|
||||||
case 'G':
|
case 'G':
|
||||||
|
|
Loading…
Reference in New Issue
Block a user