Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

File::MMagic doesn't recognize rar file

0 views
Skip to first unread message

Vilmos Soti

unread,
May 16, 2006, 12:31:29 PM5/16/06
to
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, ne...@uchicago.edu)
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. Sinan Unur

unread,
May 16, 2006, 5:10:56 PM5/16/06
to
Vilmos Soti <vil...@soti.ca> wrote in
news:lqwtcm6...@vilmos.msmri.medicine.ubc.ca:

> 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 <1u...@llenroc.ude.invalid>
(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

Vilmos Soti

unread,
May 16, 2006, 6:07:19 PM5/16/06
to
"A. Sinan Unur" <1u...@llenroc.ude.invalid> writes:

> Vilmos Soti <vil...@soti.ca> wrote in
> news:lqwtcm6...@vilmos.msmri.medicine.ubc.ca:
>
>> 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.

!@#$%

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

DJ Stunks

unread,
May 16, 2006, 7:50:30 PM5/16/06
to

Vilmos Soti wrote:
> "A. Sinan Unur" <1u...@llenroc.ude.invalid> writes:
>
> > Vilmos Soti <vil...@soti.ca> wrote in
> > news:lqwtcm6...@vilmos.msmri.medicine.ubc.ca:
> >
> >> 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.
>
> 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

A. Sinan Unur

unread,
May 16, 2006, 8:33:36 PM5/16/06
to
"DJ Stunks" <DJSt...@gmail.com> wrote in
news:1147823430.7...@i39g2000cwa.googlegroups.com:

>
> Vilmos Soti wrote:
>> "A. Sinan Unur" <1u...@llenroc.ude.invalid> writes:
>>

....


>> > and save. That should result in rar files correctly being
>> > identified as application/x-rar.
>>
>> Done, and it works now.
>>
>> Sinan, thank you for your help.

You are welcome.

> 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! :)

;-)

A. Sinan Unur

unread,
May 17, 2006, 11:10:35 AM5/17/06
to
"A. Sinan Unur" <1u...@llenroc.ude.invalid> wrote in
news:Xns97C5AED08DBF...@127.0.0.1:

> Please report this to the module author.

Fixed.

http://rt.cpan.org/Public/Bug/Display.html?id=19294

Sinan

0 new messages