List directory contents, possibly filter by the given fil func and possibly sorted.
(self, fil=None, sort=None)
| 801 | _patternchars = set(class="st">"*?[" + os.sep) |
| 802 | |
| 803 | def listdir(self, fil=None, sort=None): |
| 804 | class="st">"""List directory contents, possibly filter by the given fil func |
| 805 | and possibly sorted. |
| 806 | class="st">""" |
| 807 | if fil is None and sort is None: |
| 808 | names = error.checked_call(os.listdir, self.strpath) |
| 809 | return map_as_list(self._fastjoin, names) |
| 810 | if isinstance(fil, str): |
| 811 | if not self._patternchars.intersection(fil): |
| 812 | child = self._fastjoin(fil) |
| 813 | if exists(child.strpath): |
| 814 | return [child] |
| 815 | return [] |
| 816 | fil = FNMatcher(fil) |
| 817 | names = error.checked_call(os.listdir, self.strpath) |
| 818 | res = [] |
| 819 | for name in names: |
| 820 | child = self._fastjoin(name) |
| 821 | if fil is None or fil(child): |
| 822 | res.append(child) |
| 823 | self._sortlist(res, sort) |
| 824 | return res |
| 825 | |
| 826 | def size(self) -> int: |
| 827 | class="st">""class="st">"Return size of the underlying file object"class="st">"" |