Library code snippets
Total size of a directory
The following code includes a function to calculate the total hard disk space taken up by a directory.
<?php
$totalsize=0;
function show_dir($dir, $pos=2){
global $totalsize;
if($pos == 2)
echo "<hr><pre>";
$handle = @opendir($dir);
while ($file = @readdir ($handle)){
if (eregi("^\.{1,2}$",$file))
continue;
if (is_dir($dir.$file)) {
echo "|- ".$pos."s
<b>$file</b>\n";
show_dir("$dir.$file/",
$pos+3);
} else {
$size=filesize($dir.$file);
echo "|- ".$pos."s
$file ";
echo("$size <br>");
$totalsize=$totalsize+$size;
}
}
@closedir($handle);
if($pos == 2) echo "</pre><hr>";
return($totalsize);
}
$totalsize = show_dir("c:/winnt/system32/");
echo($totalsize);
?>
Related articles
Related discussion
-
Ventrilo Server Status Php. Snmp Server Enable Traps
by MarkHewitt (0 replies)
-
Aion Server Status Php, Server Racks Cabinets
by MarkHewitt (0 replies)
-
Moparscape Server Status Php - Global Catalog Server Could Not Be Located
by MarkHewitt (0 replies)
-
accutane online without prescription, isotretinoin online, accutane cost, accutane acne treatment
by torgo (0 replies)
-
We are seeking a highly skilled iPhone Develope
by Kim abunado (0 replies)
Related podcasts
-
EarthClassMail.com - Moving from LAMP to .NET 3.5
Scott chats with Matt Davis, architect at EarthClassMail.com, about their move from a LAMP stack (Linux/Apache/mysql/PHP) to .NET 3.5. What's working, what's not, and what kinds of issues are they running into as their architect their solution.
Events coming up
-
Apr
17
WebTech Conference 2010 - Bulgaria
Veliko Turnovo, Bulgaria
6th edition of WebTech conference will be held. A 2 day conference about : - Web Technologies - Blogs and blogging - Web 3.0 - Open Web - Mobile technologies - Internet Business
This thread is for discussions of Total size of a directory.