note 58585 added to function.filesize
| From: | cory at lavacube dot com | Date: | Tue, 08 Nov 2005 22:02:33 +0000 |
| Subject: | note 58585 added to function.filesize | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-98277@lists.php.net to get a copy of this message | ||
Oopsie! I made a mistake.
I realized that, in my stupidity, I used grep to locate "total". grep will produce a list
of all files containing the word "total".
Here is my fix, and a "human readable" addition.
<?php
function du( $dir='./', $human_read=false )
{
// human readable?
$h = ($human_read?'h':null);
// ensure path is a directory
if( !is_dir($dir) )
{
return 0;
}
// build command
$cmd = 'du -s' .$h. ' "' .$dir. '"';
// run command
$temp = explode("\t", exec($cmd));
$dirsize = trim($temp[0]);
// output result
return $dirsize;
}
?>
----
Manual Page -- http://www.php.net/manual/en/function.filesize.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+58585
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+58585&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+58585&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+58585&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+58585&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+58585&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+58585&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+58585&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+58585&report=yes
Search -- http://master.php.net/manage/user-notes.php