replace dskspace() with platform independ version (Bug #156)

This commit is contained in:
Uwe Steinmann 2014-05-16 12:48:37 +02:00
parent a20043ff10
commit 9d760dd53f

View File

@ -264,18 +264,27 @@ function createVersionigFile($document) { /* {{{ */
return true; return true;
} /* }}} */ } /* }}} */
// funcion by shalless at rubix dot net dot au (php.net) /**
* Calculate disk space of file or directory
*
* original funcion by shalless at rubix dot net dot au (php.net)
* stat() replace by filesize() to make it work on all platforms.
*
* @param string $dir directory or filename
* @return integer number of bytes
*/
function dskspace($dir) { /* {{{ */ function dskspace($dir) { /* {{{ */
$s = stat($dir); $space = 0;
$space = $s["blocks"]*512; if(is_file($dir)) {
if (is_dir($dir)) { $space = filesize($dir);
$dh = opendir($dir); } elseif (is_dir($dir)) {
while (($file = readdir($dh)) !== false) $dh = opendir($dir);
if ($file != "." and $file != "..") while (($file = readdir($dh)) !== false)
$space += dskspace($dir."/".$file); if ($file != "." and $file != "..")
closedir($dh); $space += dskspace($dir."/".$file);
} closedir($dh);
return $space; }
return $space;
} /* }}} */ } /* }}} */
function add_log_line($msg="") { /* {{{ */ function add_log_line($msg="") { /* {{{ */