from pathlib import Path


def filetype_of(path: Path) -> str:
    """
    Returns the type of file a path is.

    Returns "vmrk", "dat", "func", or "unsorted".
    """

    filetype = "unsorted"

    if path.suffix == ".vmrk":
        filetype = "vmrk"

    elif path.suffix == ".dat":
        filetype = "dat"

    elif path.suffix == ".nii":
        if "bold" in path.stem:
            filetype = "func"

    return filetype