<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def listdir(self, pattern=None):
 """Returns a list of all the files in this directory. The special entries ``'.'`` and ``'..'`` will not be returned. :param pattern: A pattern to match directory entries against. :type pattern: NoneType | Callable | Pattern | unicode | bytes """

        files = [self / self.__class__(p) for p in os.listdir(self.path)]
        if pattern is None:
            pass
        elif callable(pattern):
            files = filter(pattern, files)
        else:
            if isinstance(pattern, backend_types):
                if isinstance(pattern, bytes):
                    pattern = pattern.decode(self._encoding, 'replace')
                start, full_re, _int_re = pattern2re(pattern)
            elif isinstance(pattern, Pattern):
                start, full_re = pattern.start_dir, pattern.full_regex
            else:
                raise TypeError("listdir() expects pattern to be a callable, "
                                "a regular expression or a string pattern, "
                                "got %r" % type(pattern))
            # If pattern contains slashes (other than first and last chars),
            # listdir() will never match anything
            if start:
                return []
            files = [f for f in files if full_re.search(f.unicodename)]
        return files