from pathlib import Path
import hashlib


def generate_dirname(filepath: Path) -> str:
    """Create a dirname using given file path.

    Parameters
    ----------
    filepath
        The path of the source file to base on.

    Returns
    -------
    str
        Generated dirname in $filename-$sha256hash format
    """
    hasher = hashlib.sha256()
    BUFSIZE = 65536
    with open(filepath, "rb") as f:
        while True:
            data = f.read(BUFSIZE)
            if not data:
                break
            hasher.update(data)
    return f"{filepath.name}-{hasher.hexdigest()}"