Public feed
#724756
function getDirectorySize($path)
{
$rv = array('totalsize' => 0, 'totalcount' => 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['totalcount'];
if (is_dir($nextpath))
{
++$rv['dircount'];
array_push($stack, $nextpath);
}
else
{
$rv['totalsize'] += filesize($nextpath);
}
}
}
}
return $rv;
}