note 28243 deleted from function.filesize by aidan
| From: | aidan@php.net | Date: | Sun, 26 Sep 2004 00:21:33 +0000 |
| Subject: | note 28243 deleted from function.filesize by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-77347@lists.php.net to get a copy of this message | ||
Note Submitter: dmitri926 AT yahoo DOT com
----
i created function dir_size, it finds out the size of files in a directory and its subdirectories
using recursion. it returns the total size in bytes.
function dir_size($dir) {
$totalsize=0;
if ($dirstream = @opendir($dir)) {
while (false !== ($filename = readdir($dirstream))) {
if ($filename!="." && $filename!="..")
{
if (is_file($dir."/".$filename))
$totalsize+=filesize($dir."/".$filename);
if (is_dir($dir."/".$filename))
$totalsize+=dir_size($dir."/".$filename);
}
}
}
closedir($dirstream);
return $totalsize;
}