def get_dir_from_zipfile(zip_file, fallback=None):
    """Return the name of the root folder in a zip file.

    :param zip_file: a :class:`zipfile.ZipFile` instance.
    :param fallback: if `None`, the name of the zip file is used. This is
        returned if the zip file contains more than one top-level directory,
        or none at all.
    """
    fallback = fallback or zip_file.filename
    directories = [name for name in zip_file.namelist() if name.endswith("/")
                   and len(PurePath(name).parts) == 1]
    return fallback if len(directories) > 1 else directories[0]
def visitdir(self, path):
        """Similar to matcher.visitdir"""
        path = normalizerootdir(path, "visitdir")
        if self.matchrecursive:
            return "all"
        elif self.unsurerecursive:
            return True
        elif path == "":
            return True

        if self._kindpats and self._compiledpats(path):
            # XXX: This is incorrect. But re patterns are already used in
            # production. We should kill them!
            # Need to test "if every string starting with 'path' matches".
            # Obviously it's impossible to test *every* string with the
            # standard regex API, therefore pick a random strange path to test
            # it approximately.
            if self._compiledpats("%s/*/_/-/0/*" % path):
                return "all"
            else:
                return True

        if self._globdirpats and self._compileddirpats(path):
            return True

        subdir, rest = self._split(path)
        subtree = self.get(subdir)
        if subtree is None:
            return False
        else:
            return subtree.visitdir(rest)