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

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

    if ((fil is None) and (sort is None)):
        names = py.error.checked_call(os.listdir, self.strpath)
        return map_as_list(self._fastjoin, names)
    if isinstance(fil, py.builtin._basestring):
        if (not self._patternchars.intersection(fil)):
            child = self._fastjoin(fil)
            if exists(child.strpath):
                return [child]
            return []
        fil = common.FNMatcher(fil)
    names = py.error.checked_call(os.listdir, self.strpath)
    res = []
    for name in names:
        child = self._fastjoin(name)
        if ((fil is None) or fil(child)):
            res.append(child)
    self._sortlist(res, sort)
    return res
