You are here

private function FileBase::scanDirectory in Forena Reports 7.5

Same name and namespace in other branches
  1. 8 src/File/FileBaseOld.php \Drupal\forena\File\FileBase::scanDirectory()
1 call to FileBase::scanDirectory()
FileBase::scanInclude in src/File/FileBase.php
Parse a drectory

File

src/File/FileBase.php, line 32
FileBase.inc File toolbox for manipulating files contained tn the report directory.

Class

FileBase

Namespace

Drupal\forena\File

Code

private function scanDirectory($directory, &$files, $recursive = TRUE) {

  // Loop through the directories, ignoring hidden files.
  $path = $directory;

  // Scan the directory for files.
  $d = @dir($path);
  if ($d) {
    while (false !== ($rpt_file = $d
      ->read())) {
      $src_file = rtrim($d->path, '/') . '/' . trim($rpt_file, '/');
      if (is_file($src_file)) {
        @(list($base_file, $ext) = explode('.', $rpt_file, 2));
        if (array_search($ext, $this->cached_extensions) !== FALSE) {
          $files[$ext][$src_file] = filemtime($src_file);
        }
      }
      elseif (is_dir($src_file)) {
        if (strpos($rpt_file, '.') !== 0 && $recursive) {
          $this
            ->scanDirectory($src_file, $files, $recursive);
        }
      }
    }
  }
  if ($d) {
    $d
      ->close();
  }
}