You are here

public function FancyFileDeleteDirectoryOnlyRecursiveFilterIterator::accept in Fancy File Delete 2.0.x

File

src/FancyFileDeleteDirectoryOnlyRecursiveFilterIterator.php, line 21

Class

FancyFileDeleteDirectoryOnlyRecursiveFilterIterator
Class FancyFileDeleteDirectoryOnlyRecursiveFilterIterator.

Namespace

Drupal\fancy_file_delete

Code

public function accept() {
  if ($this
    ->current()
    ->isReadable()) {
    $filename = $this
      ->current()
      ->getFilename();

    // Skip hidden files and directories.
    if ($filename[0] === '.') {
      return FALSE;
    }
    if (!$this
      ->isDir()) {
      return FALSE;
    }
    $path = $this
      ->current()
      ->getPathname();
    foreach ($this->_exclude_paths as $exclude_path) {
      if (strpos($path, $exclude_path) === 0) {
        return FALSE;
      }
    }
    return TRUE;
  }
  return FALSE;
}