Mailinglisten-Archive |
Hi Jens,
Tschuldigung! Geht natürlich nicht so, weil rekusiv:
<snip>
function size_dir($dir) {
$handle = _(at)_opendir($dir);
while ($file = _(at)_readdir ($handle)) {
if (eregi("^\.{1,2}$",$file)) continue;
if(is_dir($dir.$file)) {
$size = $size + size_dir($dir.$file."/");
} else {
$size = $size + filesize($dir.$file);
}
}
_(at)_closedir($handle);
return $size;
}
function size_format($size) {
$ext = " Byte";
if($size > 1024) {
$ext = " kByte";
$size = $size / 1024;
if($size > 1024) {
$size = $size / 1024;
$ext = " MByte";
}
}
$size = round($size * 100) / 100;
$size = $size.$ext;
return $size;
}
<snap>
Aufruf z.B:
echo size_format(size_dir("/blafasel/dideldum/dei/"));
So, Jetzt gehts und ist getestet! ;-))
Manchmal ist man halt ein bisserl voreilig!
MFG Wolfgang
php::bar PHP Wiki - Listenarchive