Permalink
Browse files

Moved from File::Type to File::LibMagic

Signed-off-by: Michal Ludvig <mludvig@logix.net.nz>
  • Loading branch information...
1 parent 4c01a66 commit 3bd44d9b6c7efb93c4074b0f5d77fa02fbd531a4 @mludvig committed Jul 30, 2012
Showing with 12 additions and 8 deletions.
  1. +12 −8 smtp-cli
View
@@ -11,6 +11,10 @@ my $version = "3.2";
#
# ChangeLog:
+# - Moved from File::Type to File::LibMagic
+# (File::Type is no longer maintained and not available
+# in EPEL for RHEL 6)
+#
# * Version 3.2 (2012-06-26)
# - Fixed syntax error
#
@@ -186,10 +190,10 @@ if (not $mime_lite and not $missing_modules_ok) {
$missing_modules_count++;
}
-## File::Type dependency is optional
-my $file_type = eval { require File::Type; File::Type->new(); };
-if (not $file_type and not $missing_modules_ok) {
- warn("!!! File::Type -- optional module not found\n");
+## File::LibMagic dependency is optional
+my $file_libmagic = eval { require File::LibMagic; File::LibMagic->new(); };
+if (not $file_libmagic and not $missing_modules_ok) {
+ warn("!!! File::LibMagic -- optional module not found\n");
warn("!!! Used for guessing MIME types of attachments\n\n");
$missing_modules_count++;
}
@@ -685,11 +689,11 @@ sub find_email_addr($)
sub guess_mime_type($)
{
my $filename = shift;
- if (defined($file_type)) {
- ## Use File::Type if possible
- return $file_type->mime_type($filename);
+ if (defined($file_libmagic)) {
+ ## Use File::LibMagic if possible
+ return $file_libmagic->checktype_filename($filename);
} else {
- ## Module File::Type is not available
+ ## Module File::LibMagic is not available
## Still recognise some common extensions
return "image/jpeg" if ($filename =~ /\.jpe?g/i);
return "image/gif" if ($filename =~ /\.gif/i);

0 comments on commit 3bd44d9

Please sign in to comment.