You are here

function boost_count_all_files in Boost 6

Count the number of files in a folder

Parameters

string $path: Directory name, usually BOOST_ROOT_CACHE_DIR or /cache

float $timer: Internal timer so function doesn't run forever

bool $first: Indicator for top call in recursive function

1 call to boost_count_all_files()
boost_admin_boost_performance_page in ./boost.admin.inc
Form builder; Displays Boost's configuration page.

File

./boost.admin.inc, line 1548
All the code for the Boost module's administrative interface.

Code

function boost_count_all_files($path, &$timer = NULL, $first = TRUE) {
  $files = 0;

  // Prevent timeouts
  if (is_null($timer)) {
    $timer = _boost_microtime_float();
  }
  if (_boost_microtime_float() - $timer > 7) {
    return $files;
  }

  // Get File Count
  $paths = glob($path . '*', GLOB_MARK | GLOB_ONLYDIR | GLOB_NOSORT);
  $files = count(glob($path . '*.*', GLOB_NOSORT));
  if ($paths) {
    foreach ($paths as $path) {
      $files += boost_count_all_files($path, $timer, FALSE);
    }
  }

  // If we ran out of time round and add a ++ to the file count
  if ($first && _boost_microtime_float() - $timer > 10) {
    return round($files, -2) . '++';
  }
  else {
    return $files;
  }
}