Jump to content

How to modify this code to reflect child dirs ???


presso

Recommended Posts

I have this snippet of code which is what i am sort of after but after alot of trying different things i have been able to get it do do what i want. Currently this bit of code will return the amount of dirs , files and current size of all files combined that is sent in $path , what i would like to be able to do is the same thing but it also includes all the child dirs and files with the $path dir , could somebody point me in the right direction for this if at all possible.

 

$path="set path here";
$totalsize = 0;
  $totalcount = 0;
  $dircount = 0;
  if ($handle = opendir ($path))
  {
    while (false !== ($file = readdir($handle)))
    {
      $nextpath = $path . '/' . $file;
      if ($file != '.' && $file != '..' && !is_link ($nextpath))
      {
        if (is_dir ($nextpath))
        {
          $dircount++;
          $result = ($nextpath);
          $totalsize += $result['size'];
          $totalcount += $result['count'];
          $dircount += $result['dircount'];
        }
        elseif (is_file ($nextpath))
        {
          $totalsize += filesize ($nextpath);
          $totalcount++;
        }
      }
    }
  }
  closedir ($handle);

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.