def METHOD_NAME(f):
    if not f.root.path:
        return struct(
            proto_path = ".",
            file_name = f.short_path,
        )
    # `f.path` looks like "<genfiles>/external/<repo>/(_virtual_imports/<library>/)?<file_name>"
    repo_name, _, file_name = f.path[len(paths.join(f.root.path, "external") + "/"):].partition("/")
    if file_name.startswith("_virtual_imports/"):
        # This is a virtual import; move "_virtual_imports/<library>" from `repo_name` to `file_name`.
        repo_name = paths.join(repo_name, *file_name.split("/", 2)[:2])
        file_name = file_name.split("/", 2)[-1]
    return struct(
        proto_path = paths.join(f.root.path, "external", repo_name),
        file_name = file_name,
    )