summaryrefslogtreecommitdiff
path: root/bin/make-mimetypes
diff options
context:
space:
mode:
authorPatrick Spek <p.spek@tyil.nl>2018-12-05 11:37:54 +0100
committerPatrick Spek <p.spek@tyil.nl>2018-12-05 11:37:54 +0100
commitbc8b5802771709b62decc47862c19c4c7eab16f4 (patch)
tree8caa5a455ae448b543ca62087a34709725e6217c /bin/make-mimetypes
parent822a2a28f3f42cdc351ffa2d40c823400c44621f (diff)
Add Dockerfile
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)";
+}