Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Mueller <thomas.mueller@tmit.eu>2013-01-02 17:35:45 +0400
committerThomas Mueller <thomas.mueller@tmit.eu>2013-01-02 17:35:45 +0400
commit2d36a20a1df4129608e9573cea3dcbb2e9de2d12 (patch)
treed0d767933a3ba4d8ef821c2554c3f4185749417a /lib/helper.php
parent516464ba94a73e9151702ddd08dae1b7501dc79c (diff)
moving storage calculation code to OC_Helper::getStorageInfo()
Diffstat (limited to 'lib/helper.php')
-rw-r--r--lib/helper.php19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/helper.php b/lib/helper.php
index be4e4e52677..c870536eb52 100644
--- a/lib/helper.php
+++ b/lib/helper.php
@@ -758,4 +758,23 @@ class OC_Helper {
}
return $str;
}
+
+ /**
+ * 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);
+ }
}