Public feed
#724761
function getDirectorySize($path)
{
$rv = array('size' => 0, 'count' => 0, 'dircount' => 0);
$base = $path;
$stack = array($path);
while (($dir = opendir(array_pop($stack))) !== false)
{
while (($file = readdir($dir)) !== false)
{
if ($file != '.' && $file != '..')
{
$nextpath = "$base/$file";
++$rv['count'];
if (is_dir($nextpath))
{
++$rv['dircount'];
array_push($stack, $nextpath);
}
elseif (is_file($nextpath))
{
$rv['size'] += filesize($nextpath);
}
}
}
}
return $rv;
}