private static function doGlobForPath($path, $options) {
    $dirname = static::getDirNameForPath($path);
    $basename = static::getBaseNameForPath($path);

    $expanded_path = static::splitPathOnWildcard($dirname);
    if ($expanded_path === false) {
      return static::doGlobForExpandedPath($path, $options);
    }

    // Use glob to get the directory expansion for the wildcard path.
    $path = $expanded_path[0] . $expanded_path[1];
    $dirs = static::doGlobForPath($path, GLOB_ONLYDIR);
    $results = [];
    foreach ($dirs as $dir) {
      // Stitch the full path back together and then recurse.
      $dirname = $expanded_path[0] . $dir . $expanded_path[2];
      $path = $dirname . DIRECTORY_SEPARATOR . $basename;
      $subdir = static::doGlobForPath($path, $options);
      $results = array_merge($results, $subdir);
    }
    return $results;
  }