File::MMagic doesn't recognize rar file

Discussion in 'Perl Misc' started by Vilmos Soti, May 16, 2006.

  1. Vilmos Soti

    Vilmos Soti Guest

    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, )
    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
    Vilmos Soti, May 16, 2006
    #1
    1. Advertising

  2. Vilmos Soti <> wrote in
    news::

    > 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 <>
    (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
    A. Sinan Unur, May 16, 2006
    #2
    1. Advertising

  3. Vilmos Soti

    Vilmos Soti Guest

    "A. Sinan Unur" <> writes:

    > Vilmos Soti <> wrote in
    > news::
    >
    >> 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
    Vilmos Soti, May 16, 2006
    #3
  4. Vilmos Soti

    DJ Stunks Guest

    Vilmos Soti wrote:
    > "A. Sinan Unur" <> writes:
    >
    > > Vilmos Soti <> wrote in
    > > news::
    > >
    > >> 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
    DJ Stunks, May 17, 2006
    #4
  5. "DJ Stunks" <> wrote in
    news::

    >
    > Vilmos Soti wrote:
    >> "A. Sinan Unur" <> 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! :)


    ;-)

    Sinan

    --
    A. Sinan Unur <>
    (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
    A. Sinan Unur, May 17, 2006
    #5
  6. A. Sinan Unur, May 17, 2006
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    5
    Views:
    338
  2. Oliver Hoehle
    Replies:
    0
    Views:
    1,761
    Oliver Hoehle
    Feb 26, 2004
  3. dongdong
    Replies:
    5
    Views:
    536
    dongdong
    Mar 8, 2006
  4. Replies:
    1
    Views:
    361
  5. K P S
    Replies:
    5
    Views:
    225
    Peter J. Holzer
    Jun 22, 2006
Loading...

Share This Page