note 72176 deleted from function.readdir by tularis
| From: | tularis@php.net | Date: | Sun, 13 May 2007 18:58:57 +0000 |
| Subject: | note 72176 deleted from function.readdir by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-126498@lists.php.net to get a copy of this message | ||
Note Submitter: golubovicm at gmail dot com
----
Function that get dir (and all it childs) size:
function dirsize($path,$top=true)
{
static $total_size=0;
if ($top==true) $total_size=0;
if (is_dir($path)) {
$dir=opendir ($path);
while (($item = readdir($dir)) !== false) {
if ($item=="." || $item=="..") continue;
$full_path="$path/$item";
if (is_file($full_path))
$total_size+=filesize($full_path);
else if (is_dir($full_path))
dirsize($full_path,false);
}
closedir($dir);
return $total_size;
}else
return -1;
}