note 64208 added to function.disk-total-space
| From: | php-net at kdcinfo dot com | Date: | Mon, 10 Apr 2006 00:40:27 +0000 |
| Subject: | note 64208 added to function.disk-total-space | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-107674@lists.php.net to get a copy of this message | ||
My first contribution also, but alas, its only an enhancement (prior post tweak). I didn't just
want the grand total of the directories and subdirectories scanned, as "shalless at rubix dot
net dot au" graciously listed, but the total for each directory. I can then take that list into
my spreadsheet app, and sort it based on size and find out which directories are eating up the most
space (or those that are empty).
I put the tilde ( ~ ) in there for easier porting into my spreadsheet app, using it as a delimiter.
In addition, I store this utility in a directory one level down from my root, so using the
"../" does my entire root.
<?
echo "<br><br>".dskspace("../");
function dskspace($dir)
{ $s = stat($dir);
$space = $s["blocks"]*512;
if (is_dir($dir))
{ $dh = opendir($dir);
while (($file = readdir($dh)) !== false)
if ($file != "." and $file != "..")
$space += dskspace($dir."/".$file);
echo "<br>".round(($space/1024)/1024,2)." Mb ~
<strong>".$dir.$file."</strong>";
closedir($dh);
}
return $space;
}
?>
Never thought I'd know enough to post here :)
http://kdcinfo.com/kdc_projects.shtml
----
Server IP: 216.194.113.175
Probable Submitter: 67.172.202.114
----
X-Spam-Status: No, hits=3.3 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER,
HTML_MESSAGE autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.disk-total-space.php
Edit -- http://master.php.net/note/edit/64208
Del: integrated -- http://master.php.net/note/delete/64208/integrated
Del: useless -- http://master.php.net/note/delete/64208/useless
Del: bad code -- http://master.php.net/note/delete/64208/bad+code
Del: spam -- http://master.php.net/note/delete/64208/spam
Del: non-english -- http://master.php.net/note/delete/64208/non-english
Del: in docs -- http://master.php.net/note/delete/64208/in+docs
Del: other reasons-- http://master.php.net/note/delete/64208
Reject -- http://master.php.net/note/reject/64208
Search -- http://master.php.net/manage/user-notes.php