You are here

function _filebrowser_dir_stats in Filebrowser 6

1 call to _filebrowser_dir_stats()
theme_filebrowser_admin_settings in ./filebrowser.module

File

./filebrowser.module, line 317

Code

function _filebrowser_dir_stats($dir) {
  $file_count = 0;
  $total_size = 0;
  if (is_dir($dir) && ($dh = opendir($dir))) {
    while (($file = readdir($dh)) !== false && is_readable($dir . '/' . $file)) {

      // Exclude fake directories
      if ($file == '.' || $file == '..') {
        continue;
      }
      $full_path = $dir . '/' . $file;
      $f_size = filesize($full_path);
      $total_size += $f_size;
      ++$file_count;
    }
    closedir($dh);
  }
  return array(
    'file_count' => $file_count,
    'total_size' => $total_size,
  );
}