note 76005 modified in function.filesize by danbrown

From: Date: Sun, 18 Jan 2009 18:06:12 +0000
Subject: note 76005 modified in function.filesize by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-149406@lists.php.net to get a copy of this message
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. --was-- 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.. 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. http://php.net/manual/en/function.filesize.php

« previous php.notes (#149406) next »