private static function doGlobForExpandedPath($filename, $options) {
    $openpath = static::getDirNameForPath($filename);
    $dirname = pathinfo($filename, PATHINFO_DIRNAME);
    $basename = static::getBaseNameForPath($filename);

    $results = [];
    $handle = @opendir($openpath);

    if ($handle === false) {
      return false;
    }
    while (($name = readdir($handle)) !== false) {
      if (static::isFileNamePatternMatch($name, $basename, $options)) {
        if (strpos($filename, DIRECTORY_SEPARATOR) !== false) {
          $name = $dirname . DIRECTORY_SEPARATOR . $name;
        }
        $results[] = $name;
      }
    }
    closedir($handle);

    if ($options & (GLOB_MARK | GLOB_ONLYDIR)) {
      $results = static::doDirectoryOptions($dirname, $results, $options);
    }

    return $results;
  }