summaryrefslogtreecommitdiff
path: root/bin/make-mimetypes
diff options
context:
space:
mode:
Diffstat (limited to 'bin/make-mimetypes')
-rwxr-xr-xbin/make-mimetypes36
1 files changed, 36 insertions, 0 deletions
diff --git a/bin/make-mimetypes b/bin/make-mimetypes
new file mode 100755
index 0000000..64c9120
--- /dev/null
+++ b/bin/make-mimetypes
@@ -0,0 +1,36 @@
+#!/usr/bin/env perl6
+
+use v6.c;
+
+sub MAIN (
+ Str:D :$default = "application/octet-stream",
+) {
+ my IO::Path $mime-types = "/etc/mime.types".IO;
+
+ die "No $mime-types.absolute()" unless $mime-types.f;
+
+ my %types;
+
+ for $mime-types.lines -> $line {
+ my ($mimetype, @extensions) = $line.words;
+
+ for @extensions -> $extension {
+ %types{$extension} = $mimetype;
+ }
+ }
+
+ print-conf(%types, $default);
+}
+
+sub print-conf (
+ %mimetypes,
+ Str:D $default,
+) {
+ say "mimetype.assign = (";
+
+ for %mimetypes.kv -> $extension, $type {
+ say "\t\".$extension\" => \"$type\",";
+ }
+
+ say "\"\" => \"$default\"\n)";
+}