note 76005 deleted from function.filesize by aharvey
| From: | aharvey@php.net | Date: | Tue, 22 Jan 2013 00:20:01 +0000 |
| Subject: | note 76005 deleted from function.filesize by aharvey | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-193327@lists.php.net to get a copy of this message | ||
Note Submitter: Robin Leffmann
----
Here's a dodgy little snippet I made to find out how much disk space (in 1K-blocks) any chosen
node - file or directory - occupies in the file system..
<?php
function nodesize( $node )
{
if( !is_readable($node) ) return false;
$blah = exec( "/usr/bin/du -sk $node" );
return substr( $blah, 0, strpos($blah, 9) );
}
?>
The character I search for with strpos() is a tab, as this is what 'du' on OpenBSD uses to
separate size and node in the output - this might be whitespaces in other *nixes/distributions.