'Helper returning files and directories in given directory listing, with
attributes to be used to build a table content with
C{self.linePattern}.
@return: tuple of (directories, files)
@rtype: C{tuple} of C{list}'

def _getFilesAndDirectories(self, directory):

    files = []
    dirs = []
    for path in directory:
        if _PY3:
            if isinstance(path, bytes):
                path = path.decode('utf8')
        url = quote(path, '/')
        escapedPath = escape(path)
        childPath = filepath.FilePath(self.path).child(path)
        if childPath.isdir():
            dirs.append({'text': (escapedPath + '/'), 'href': (url + '/'), 'size': '', 'type': '[Directory]', 'encoding': ''})
        else:
            (mimetype, encoding) = getTypeAndEncoding(path, self.contentTypes, self.contentEncodings, self.defaultType)
            try:
                size = childPath.getsize()
            except OSError:
                continue
            files.append({'text': escapedPath, 'href': url, 'type': ('[%s]' % mimetype), 'encoding': ((encoding and ('[%s]' % encoding)) or ''), 'size': formatFileSize(size)})
    return (dirs, files)
