def subject_to_csv_line(subject, filename, base = nil, index = nil)
      line = []

      if map_to_csv
        map_to_csv.each do |col, opt|
          if opt.is_a?(Proc)
            entry = opt.call(subject, filename, base, index)
          else
            entry = subject.send(opt)
          end

          entry = entry.to_s if entry.is_a?(BinData::String)
          if entry.is_a?(String)
            entry.gsub!('"', '\"')
            entry = "\"#{entry}\""
          end
          entry = entry.to_s.encode!('UTF-8', 'UTF-8', :invalid => :replace)

          # HACK
          entry.chop! if entry.end_with?("\x00")

          line << entry
        end
      else
        raise "TODO"
      end

      return line.join(SEPERATOR)
    end
def subject_to_csv_line(subject, filename, base = nil, index = nil)
      line = []

      if map_to_csv
        map_to_csv.each do |col, opt|
          if opt.is_a?(Proc)
            entry = opt.call(subject, filename, base, index)
          else
            entry = subject.send(opt)
          end

          entry = entry.to_s if entry.is_a?(BinData::String)
          if entry.is_a?(String)
            entry.gsub!('"', '\"')
            entry = "\"#{entry}\""
          end
          entry = entry.to_s.encode!('UTF-8', 'UTF-8', :invalid => :replace)

          # HACK
          entry.chop! if entry.end_with?("\x00")

          line << entry
        end
      else
        raise "TODO"
      end

      return line.join(SEPERATOR)
    end
def fields_from_mpq_reader
      fields = MPQ_READER.fields.fields.map { |e| e.name }
      if fields.include?
    end