'list directory contents, possibly filter by the given fil func
and possibly sorted.'

def listdir(self, fil=None, sort=None):

    if isinstance(fil, str):
        fil = common.FNMatcher(fil)
    nameinfo_seq = self._listdir_nameinfo()
    if (len(nameinfo_seq) == 1):
        (name, info) = nameinfo_seq[0]
        if ((name == self.basename) and (info.kind == 'file')):
            raise py.error.ENOTDIR(self)
    paths = [self.join(name) for (name, info) in nameinfo_seq]
    if fil:
        paths = [x for x in paths if fil(x)]
    self._sortlist(paths, sort)
    return paths
