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