File::MMagic doesn't recognize rar file

V

Vilmos Soti

Hello,

File::MMagic doesn't seem to recognize rar files. (tar is ok).
The machine is running Debian Etch. Here is the perl version:

$ perl -v

This is perl, v5.8.8 built for i486-linux-gnu-thread-multi

Copyright 1987-2006, Larry Wall
....

Here is the version of File::MMagic:

$ head -3 /usr/share/perl5/File/MMagic.pm
# File::MMagic
#
# $Id: MMagic.pm 198 2006-01-30 05:24:17Z knok $
$

Here is my script:

############################## Script starts ##############################
#!/usr/bin/perl -w
use strict;
use File::MMagic;

my $magic = new File::MMagic;
my $type;

foreach my $file (<c.*>) {
$type = $magic->checktype_filename ("$file");
print "$file, $type\n";
system ("file $file");
print "\n";
}
############################## Script ends ##############################

And here is the output of the script:

$ ./a
c.rar, application/octet-stream
c.rar: RAR archive data, v1d, os: Win32

c.tar, application/x-gtar
c.tar: POSIX tar archive

$

Here are the last two lines from /usr/share/perl5/File/MMagic.pm:

# RAR archiver (Greg Roelofs, (e-mail address removed))
0 string Rar! application/x-rar

And here are the first few characters from c.rar:

$ xxd c.rar | head -1
0000000: 5261 7221 1a07 00cf 9073 0000 0d00 0000 Rar!.....s......
$

Do I do anything wrong or is it something else?

Thanks for your time, Vilmos
 
A

A. Sinan Unur

File::MMagic doesn't seem to recognize rar files. (tar is ok).
The machine is running Debian Etch.

rar is the last entry in the file and there is no newline after that entry
which causes that line of data to be missed.

Edit your copy of MMagic: Go to the end of the line, press enter, and
save. That should result in rar files correctly being identified as
application/x-rar.

Please report this to the module author.

Sinan

--
A. Sinan Unur <[email protected]>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
 
V

Vilmos Soti

A. Sinan Unur said:
rar is the last entry in the file and there is no newline after that entry
which causes that line of data to be missed.

!@#$%

My copy does have a newline, but it doesn't have an empty line.
Maybe this was the problem. Now it works.
Edit your copy of MMagic: Go to the end of the line, press enter, and
save. That should result in rar files correctly being identified as
application/x-rar.

Done, and it works now.
Please report this to the module author.

I did.

Sinan, thank you for your help.

Vilmos
 
D

DJ Stunks

Vilmos said:
Done, and it works now.

Sinan, thank you for your help.

Another example of how a good posting technique is directly
proportional to the quality of the responses.

Excellent post, and great job picking that up, Sinan.

gooooo team! :)

-jp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top