1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
#!/usr/bin/ruby ## Parses mime.types and creates mime.dat file = File.read(ARGV.first || "mime.types") table = {} for line in file.lines next if line[0] == ?# or line.size <= 3 or !line.include?( ?\t ) name, *extensions = line.split(/\s+/) for ext in extensions table[ext] = name end end File.open( 'mime.dat', 'w' ) do |f| f.write Marshal.dump( table ) end