# ---------------------------------------------------------------------------
# directory creation  (makedirs)
# ---------------------------------------------------------------------------
def safe_join(*paths):
    """``os.path.join`` that silently drops falsy components."""
    paths = [path for path in paths if path]
    return os.path.join(*paths)


def raw_create_dirs(*paths):
    """Recursively create every directory along the given path and return it."""
    full_path = os.path.abspath(safe_join(*paths))
    sub_parts = [p for p in full_path.split(os.sep) if p]

    current_path = "/" if full_path.startswith(os.sep) else ""
    for part in sub_parts:
        current_path = safe_join(current_path, part)
        os.makedirs(current_path, exist_ok=True)
    return full_path


# ``makedirs`` in the package is just an alias of ``raw_create_dirs``.
makedirs = raw_create_dirs
