diff options
Diffstat (limited to 'lib/helper.php')
-rw-r--r-- | lib/helper.php | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/helper.php b/lib/helper.php index 1a634075bd1..425dc138c5a 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -782,4 +782,23 @@ class OC_Helper { } return true; } + + /** + * Calculate the disc space + */ + public static function getStorageInfo() { + $rootInfo = OC_FileCache::get(''); + $used = $rootInfo['size']; + if ($used < 0) { + $used = 0; + } + $free = OC_Filesystem::free_space(); + $total = $free + $used; + if ($total == 0) { + $total = 1; // prevent division by zero + } + $relative = round(($used / $total) * 10000) / 100; + + return array('free' => $free, 'used' => $used, 'total' => $total, 'relative' => $relative); + } } |