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;
} /* }}} */
// 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) { /* {{{ */
$s = stat($dir);
$space = $s["blocks"]*512;
if (is_dir($dir)) {
$dh = opendir($dir);
while (($file = readdir($dh)) !== false)
if ($file != "." and $file != "..")
$space += dskspace($dir."/".$file);
closedir($dh);
}
return $space;
$space = 0;
if(is_file($dir)) {
$space = filesize($dir);
} elseif (is_dir($dir)) {
$dh = opendir($dir);
while (($file = readdir($dh)) !== false)
if ($file != "." and $file != "..")
$space += dskspace($dir."/".$file);
closedir($dh);
}
return $space;
} /* }}} */
function add_log_line($msg="") { /* {{{ */