Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#23 Directory size = sum of filesizes in dir

open
nobody
None
6
2009-07-17
2009-07-17
Michael Kohlert
No

add function to "fun_extra.php" :

function get_dir_size($verzeichnis, &$dirsize) {
$handle = @opendir($verzeichnis);
while ($datei = @readdir ($handle)) {
if (eregi("^\.{1,2}$",$datei)) {
continue;
}
if (is_dir($verzeichnis.'/'.$datei)) {
get_dir_size($verzeichnis.'/'.$datei, $dirsize);
} else {
$dirsize += filesize($verzeichnis.'/'.$datei);
}
}
@closedir($handle);
return $dirsize;
}

----

Look for Line in "fun_list.php":

echo "<TD class=\"header\">".parse_file_size($tot_file_size)."</TD>\n";

and change it to:

$dirsize = 0;
echo "<td class=\"header\">".parse_file_size(get_dir_size(get_abs_dir($dir),$dirsize))."</td>\n";

Discussion

    • priority: 5 --> 6