def tar_entry_size(filesize):
    """Get the space a file of the given size will actually require in a TAR.

    The entry has a 512-byte header followd by the actual file data,
    padded to a multiple of 512 bytes if necessary.

    Args:
      filesize (int): File size in bytes

    Returns:
      int: Bytes consumed in a TAR archive by this file.

    Examples:
      ::

        >>> tar_entry_size(1)
        1024
        >>> tar_entry_size(511)
        1024
        >>> tar_entry_size(512)
        1024
        >>> tar_entry_size(513)
        1536
    """
    # round up to next multiple of 512
    return 512 + filesize + ((512 - filesize) % 512)