summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRobin Appelman <icewind1991@gmail.com>2011-12-11 23:33:24 +0100
committerRobin Appelman <icewind1991@gmail.com>2011-12-11 23:33:24 +0100
commitefecb694eff7129d1ca24627ac366f3bcc939864 (patch)
tree5b5f11c68df9bf90142d78f47fcf44ff465d4f6d /lib
parentbd65c18f21ca973e90334f74e3325ae449194d42 (diff)
downloadnextcloud-server-efecb694eff7129d1ca24627ac366f3bcc939864.tar.gz
nextcloud-server-efecb694eff7129d1ca24627ac366f3bcc939864.zip
make filesize parsing case insensitive
Diffstat (limited to 'lib')
-rw-r--r--lib/helper.php25
1 files changed, 13 insertions, 12 deletions
diff --git a/lib/helper.php b/lib/helper.php
index 5b3e394cafd..24d436225b7 100644
--- a/lib/helper.php
+++ b/lib/helper.php
@@ -160,24 +160,25 @@ class OC_Helper {
*/
public static function computerFileSize( $str ){
$bytes = 0;
+ $str=strtolower($str);
$bytes_array = array(
- 'B' => 1,
- 'K' => 1024,
- 'KB' => 1024,
- 'MB' => 1024 * 1024,
- 'M' => 1024 * 1024,
- 'GB' => 1024 * 1024 * 1024,
- 'G' => 1024 * 1024 * 1024,
- 'TB' => 1024 * 1024 * 1024 * 1024,
- 'T' => 1024 * 1024 * 1024 * 1024,
- 'PB' => 1024 * 1024 * 1024 * 1024 * 1024,
- 'P' => 1024 * 1024 * 1024 * 1024 * 1024,
+ 'b' => 1,
+ 'k' => 1024,
+ 'kb' => 1024,
+ 'mb' => 1024 * 1024,
+ 'm' => 1024 * 1024,
+ 'gb' => 1024 * 1024 * 1024,
+ 'g' => 1024 * 1024 * 1024,
+ 'tb' => 1024 * 1024 * 1024 * 1024,
+ 't' => 1024 * 1024 * 1024 * 1024,
+ 'pb' => 1024 * 1024 * 1024 * 1024 * 1024,
+ 'p' => 1024 * 1024 * 1024 * 1024 * 1024,
);
$bytes = floatval($str);
- if (preg_match('#([KMGTP]?B?)$#si', $str, $matches) && !empty($bytes_array[$matches[1]])) {
+ if (preg_match('#([kmgtp]?b?)$#si', $str, $matches) && !empty($bytes_array[$matches[1]])) {
$bytes *= $bytes_array[$matches[1]];
}