You are here

function _cdn_cron_scan_directory in CDN 5

Stolen from Drupal core. Simplified for CDN cron usage. Parameter order is unchanged, so you can look at the official file_scan_directory() documentation but think away the last parameters.

See also

file_scan_directory

1 call to _cdn_cron_scan_directory()
_cdn_cron_get_files_to_sync in ./cdn_cron.inc
Generates the list of files that has to be sync, based on a file name pattern, a list of ignored directories, a list of directories of which any file will be included, and an exclude pattern.

File

./cdn_cron.inc, line 241
Basic functions for CDN synchronization cron.

Code

function _cdn_cron_scan_directory($dir, $pattern, $ignored_dirs = array(
  'CVS',
)) {
  $files = array();
  if (is_dir($dir) && ($handle = opendir($dir))) {
    while ($file = readdir($handle)) {
      if (!in_array($file, $ignored_dirs) && $file[0] != '.') {
        if (is_dir("{$dir}/{$file}")) {
          $files += _cdn_cron_scan_directory("{$dir}/{$file}", $pattern, $ignored_dirs);
        }
        elseif (ereg($pattern, $file)) {
          $files["{$dir}/{$file}"] = filesize("{$dir}/{$file}");
        }
      }
    }
    closedir($handle);
  }
  return $files;
}