# File lib/rubytorrent/metainfo.rb, line 82
  def check
    raise MetaInfoFormatError, "invalid file length" unless @s.length.nil? || @s.length >= 0
    raise MetaInfoFormatError, "one (and only one) of 'length' (single-file torrent) or 'files' (multi-file torrent) must be specified" if (@s.length.nil? && @s.files.nil?) || (!@s.length.nil? && !@s.files.nil?)
    if single?
      length = @s.length
    else
      length = @s.files.inject(0) { |s, x| s + x.length }
    end
    raise MetaInfoFormatError, "invalid metainfo file: length #{length} > (#{@s.pieces.length / 20} pieces * #{@s.piece_length})" unless length <= (@s.pieces.length / 20) * @s.piece_length
    raise MetaInfoFormatError, "invalid metainfo file: pieces length = #{@s.pieces.length} not a multiple of 20" unless (@s.pieces.length % 20) == 0
  end