Le Mon, Sep 07, 2009 at 08:38:39PM +0100, Reuben Thomas a écrit :
>
> I checked the latest version of the patch I attached to this bug, and
> it still applies cleanly to run-mailcap from 3.46-1.
Dear Thomas and everybody,
I went through the latest patch and I wonder if it can be simplified as
follows, because if a file has no suffix and is compressed, run-mailcap will
not uncompress it anyway.
--- a/run-mailcap
+++ b/run-mailcap
@@ -293,6 +293,18 @@ sub ExtensionMimetype {
+sub MagicMimetype {
+ my($file) = @_;
+ my($typ);
+
+ open(READER, "-|", "file", "-b", "--mime-type", "-e", "tokens",
"-L", "-z", $file);
+ $typ = <READER>;
+ chomp $typ;
+ return $typ;
+}
+
+
+
sub PatternMimetype {
my($file) = @_;
my($key,$val);
@@ -317,6 +329,7 @@ sub FileMimetype {
my $type;
$type = ExtensionMimetype($ext) if $ext;
+ $type = MagicMimetype($file) unless $type || !-e $file;
$type = PatternMimetype($file) unless $type;
return $type;
Cheers,
--
Charles Plessy
Tsurumi, Kanagawa, Japan
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]