From 225ad85e909b3f65d8eda57ef13001b0000e4e76 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Sun, 17 Apr 2011 16:40:44 +0200 Subject: [PATCH] add free_space to OC_FILESYSTEM --- lib/filestorage.php | 5 +++++ lib/filesystem.php | 6 ++++++ settings/index.php | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/filestorage.php b/lib/filestorage.php index 66b91fc19a..5161e7f0e5 100644 --- a/lib/filestorage.php +++ b/lib/filestorage.php @@ -75,6 +75,7 @@ class OC_FILESTORAGE{ public function find($path){} public function getTree($path){} public function hash($type,$path,$raw){} + public function free_space($path){} } @@ -466,6 +467,10 @@ class OC_FILESTORAGE_LOCAL extends OC_FILESTORAGE{ } return $return; } + + public function free_space($path){ + return disk_free_space($this->datadir.$path); + } /** * @brief get the size of folder and it's content diff --git a/lib/filesystem.php b/lib/filesystem.php index 54b2ad9ce7..033f50e2ab 100644 --- a/lib/filesystem.php +++ b/lib/filesystem.php @@ -386,5 +386,11 @@ class OC_FILESYSTEM{ return $storage->hash($type,self::getInternalPath($path),$raw); } } + + static public function free_space($path='/'){ + if(self::canRead($path) and $storage=self::getStorage($path)){ + return $storage->free_space($path); + } + } } ?> diff --git a/settings/index.php b/settings/index.php index 521f2ade9d..0e3b3f2855 100644 --- a/settings/index.php +++ b/settings/index.php @@ -10,7 +10,7 @@ if( !OC_USER::isLoggedIn()){ $tmpl = new OC_TEMPLATE( "settings", "index", "admin"); $used=OC_FILESYSTEM::filesize('/'); -$free=disk_free_space(OC_CONFIG::getValue('datadirectory')); +$free=OC_FILESYSTEM::free_space(); $total=$free+$used; $relative=round(($used/$total)*100); $tmpl->assign('usage',OC_HELPER::humanFileSize($used));