import pathlib


def str_to_pathlib(in_str):
    """
    Handle the string to pathlib.Path casting
    """
    if isinstance(in_str, pathlib.Path):
        return in_str
    else:
        try:
            return pathlib.Path(in_str)
        except:
            raise IOError("Invalid path specified.")