Thread: Directory Size
View Single Post
  #2 (permalink)  
Old 07-31-2006, 08:23 AM
Jordan's Avatar   
Jordan Jordan is offline
Administrator
 
Join Date: Nov 2005
Location: Hendersonville, NC
Posts: 10,868
Last Blog:
Artificial Intelligenc...
Credits: 1
Rep Power: 20
Jordan is just really niceJordan is just really niceJordan is just really niceJordan is just really nice
Send a message via ICQ to Jordan Send a message via AIM to Jordan Send a message via MSN to Jordan
Default

I've added comments around what I added:

PHP Code:
<?php 

// Add a variable before the loops
$totalSize 0;

$dir "../demo/themes/"
        
$tree = array(); 
        
$dirs = array(array($dir, &$tree)); 
        
        for(
$i 0$i count($dirs); ++$i
        { 
                
$d opendir($dirs[$i][0]); 
                
$tier =& $dirs[$i][1]; 

                while(
$file readdir($d)) 
                { 
                        if (
$file != '.' and $file != '..'
                        { 
                                
$path $dirs[$i][0] . DIRECTORY_SEPARATOR $file
                                if (
is_dir($path)) 
                                { 
                                        
$tier[$file] = array(); 
                                        
$dirs[] = array($path, &$tier[$file]); 
                                } 
                                else 
                                { 
                                         
                                    
$size2 filesize($path); 
                                    
                                    
// Add the Size
                                    
$totalSize += size2;

                                    
$size = array($size2); 
                                    
print_r($size); 
                                    echo 
"<br>";     
                                         
                                }     
                                                                                  
                        } 
                         
                } 
                 
        } 

  
// Show the size
  
print $totalSize;

Also, if you are using an array you should push the value so that it goes in as the last/new element. That would keep them from all being on element 0.
__________________
CodeCall Blog | CodeCall Wiki | Shareware Site | Linux Forum | Write a Blog
The CodeCall Wiki is now fully integrated with vBulletin users! Check it out and add some new pages!
Reply With Quote