You are here

function VirtualFilesystem::getDirContents in X Autoload 7.4

Same name and namespace in other branches
  1. 7.5 tests/src/Filesystem/VirtualFilesystem.php \Drupal\xautoload\Tests\Filesystem\VirtualFilesystem::getDirContents()

Parameters

string $dir:

Return value

array|bool

File

tests/lib/Filesystem/VirtualFilesystem.php, line 134

Class

VirtualFilesystem

Namespace

Drupal\xautoload\Tests\Filesystem

Code

function getDirContents($dir) {
  if (empty($this->knownPaths[$dir]) || self::DIR !== $this->knownPaths[$dir]) {
    return FALSE;
  }
  $pos = strlen($dir . '/');
  $contents = array(
    '.',
    '..',
  );
  foreach ($this->knownPaths as $path => $type) {
    if ($dir . '/' !== substr($path, 0, $pos)) {
      continue;
    }
    $name = substr($path, $pos);
    if (FALSE !== strpos($name, '/')) {

      // This is a deeper subdirectory.
      continue;
    }
    if ('' === $name) {
      continue;
    }
    $contents[] = $name;
  }
  return $contents;
}