about summary refs log tree commit diff stats
path: root/data/generate.rb
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2009-11-16 16:43:34 +0100
committerhut <hut@lavabit.com>2009-11-16 16:43:34 +0100
commitae2705f42b7ded7c3a91294154b83b541e150542 (patch)
tree8dd079e35940b0573a1733891ef42a1ab1505ccd /data/generate.rb
parent712aa449042e5f9cc66277eeb68fa18b5a0c7d57 (diff)
downloadranger-ae2705f42b7ded7c3a91294154b83b541e150542.tar.gz
added mime type database
Diffstat (limited to 'data/generate.rb')
-rwxr-xr-xdata/generate.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/data/generate.rb b/data/generate.rb
new file mode 100755
index 00000000..52a4c8e4
--- /dev/null
+++ b/data/generate.rb
@@ -0,0 +1,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
+