def _ListDir(dirpath, pathtype):
  """Returns children of a given directory.

  This function is intended to be used by the `PathComponent` subclasses to get
  initial list of potential children that then need to be filtered according to
  the rules of a specific component.

  Args:
    dirpath: A path to the directory.
    pathtype: The pathtype to use.

  Raises:
    ValueError: in case of unsupported path types.
  """
  pathspec = rdf_paths.PathSpec(path=dirpath, pathtype=pathtype)
  childpaths = []
  try:
    file_obj = vfs.VFSOpen(pathspec)
    for path in file_obj.ListNames():
      # For Windows registry, ignore the empty string which corresponds to the
      # default value in the current key. Otherwise, globbing a key will yield
      # the key itself, because joining the name of the default value u"" with
      # a key name yields the key name again.
      if pathtype != rdf_paths.PathSpec.PathType.REGISTRY or path:
        childpaths.append(path)
  except IOError:
    pass

  return childpaths