def _length(stream):
    """Returns the size of the given file stream."""
    original_offset = stream.tell()
    stream.seek(0, 2)
    size = stream.tell()
    stream.seek(original_offset)
    return size
