Größe
Verzeichnissgrösse ermitteln
|
Script: |
<?
function readsize_recursiv($path)
{
$s =
0;
$result[$path]
= 0;
$handle
= opendir($path);
if ($handle)
{
while (false
!== ($file
= readdir($handle)))
{
if
($file != "."
&& $file
!= "..")
{
$name
= $path .
"/" .
$file;
if
(is_dir($name))
{
$ar
= readsize_recursiv($name);
while
(list($key,
$value) = each
($ar))
{
$s++;
$result[$key]
= $value;
}
}
else
{
$result[$path]
+= filesize($name);
}
}
}
}
closedir($handle);
return $result;
}
$data =
readsize_recursiv(".");
$summe =
0;
while (list($key,
$value) = each
($data))
{
echo "$key
= $value byte<br>\n";
$summe +=
$value;
}
echo "Gesamtgröße:
$summe byte";
?>
|
|