import pathlib


def resolve_name(path):
    """Resolves the name of the given path.

    When using path.name to get the name of a file, pathlib returns an
    empty string for cwd and root. To get around this, we need to
    specify the proper names ourselves.

    Parameters
    ----------
    path : pathlib.Path object
        The path to resolve the name for.

    Returns
    -------
    name : string
        The resolved file name.

    """

    abspath = str(path.resolve())
    if abspath == "/":
        name = "/"
    elif abspath == str(pathlib.Path.cwd()):
        name = "."
    else:
        name = path.name

    return name