From dda80c29ed4177720c2117c46c1bd134ec61f812 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Sun, 3 Feb 2013 16:41:17 +0100 Subject: Use php's fileinfo instead of perl to detect mimetype Signed-off-by: Florian Pritz --- scripts/mimetype | 38 -------------------------------------- 1 file changed, 38 deletions(-) delete mode 100755 scripts/mimetype (limited to 'scripts') diff --git a/scripts/mimetype b/scripts/mimetype deleted file mode 100755 index 330f96ef0..000000000 --- a/scripts/mimetype +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/perl -use warnings; -use strict; -use File::MimeInfo::Magic qw(mimetype globs); - -exit 1 unless @ARGV == 2; - -my $filename = $ARGV[0]; -my $file = $ARGV[1]; -my $type = ""; -my $file_type = ""; - -exit 1 unless -f $file; - -$type = globs($filename); - -# globbing takes priority over all other -if (!$type) { - $type = mimetype($file); - if ($type eq "application/octet-stream") { - # application/octet-stream normally means the detection failed - # use the output of file in this case - $file_type = `file -b --mime-type $file`; - chomp $file_type; - $type = $file_type; - if ($type eq "text/plain") { - # detect ascii with color codes - $file_type = `file -b $file`; - chomp $file_type; - if ($file_type =~ m/ASCII text, (?:with very long lines, )?with escape sequences/) { - $type = "text/plain-ascii"; - } - } - } -} - -print "$type\n"; - -- cgit v1.2.3-24-g4f1b