note 58430 added to function.filesize

From: Date: Fri, 04 Nov 2005 05:12:31 +0000
Subject: note 58430 added to function.filesize
Groups: php.notes 
Request: Send a blank email to php-notes+get-98046@lists.php.net to get a copy of this message
For Linux/Unix users: A simple recursive way to get the total of a directory using the "du" command: <?php function du( $dir='./' ) { // apply ending slash -- probably not necessary $dir = (substr($dir, 0, -1)!='/'?$dir.'/':$dir); // ensure path is a directory if( !is_dir($dir) ) { return 0; } // build command $cmd = 'du -c "' .$dir. '" |grep total'; // run command $dirsize = str_replace('total', null, cmd($cmd)); // output result return trim($dirsize); } ?> This could more than likely be cleaned up, but it works. :-) ---- Manual Page -- http://www.php.net/manual/en/function.filesize.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+58430 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+58430&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+58430&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+58430&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+58430&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+58430&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+58430&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+58430&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+58430&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#98046) next »