http://www.perlmonks.org?node_id=1084319

pankaj_it09 has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,

The above mentioned package requires shared-mime-info database .
I downloaded the database and tried integrating it.
Unable to do so.
How to do that ?

Below is the code -->
use strict; use File::MimeInfo::Magic; use File::Find 'find'; open(FILE,'>>','fileType.csv'); my $inputDirectory = 'F:/'; find({wanted => sub {\&scanFiles();},no_chdir => 1},$inputDirectory); sub scanFiles { my $mimeType = mimetype($File::Find::name); print FILE "$File::Find::name,$mimeType\n"; } close(FILE);
Below is the warning -->

WARNING: You don't seem to have a mime-info database. The shared-mime-info package is available from http://freedesktop.org/

Replies are listed 'Best First'.
Re: File::MimeInfo::Magic in Windows
by marto (Cardinal) on Apr 29, 2014 at 13:30 UTC

    The devil is in the detail. What you haven't explicitly told us in this post is that you're using Microsoft Windows (as you mentioned in the Chatterbox). What you didn't notice was the warnings when you installed the required modules:

    t/00_use_ok.t ...... 1/4 WARNING: You don't seem to have any mimeinfo. +cache files. Try running the update-desktop-database command. If you don't have this command you should install the desktop-file-utils package. This package is available from http://freedesktop.org/wiki/Software/desktop-file-utils/

    I suggest you investigate these issues. It looks as though there are Windows ports of what's required (shared-mime-info, parts of gnuwin32) etc.

    Update: Reworded, added some links.

Re: File::MimeInfo::Magic in Windows
by Anonymous Monk on Apr 30, 2014 at 00:07 UTC
    When you download the mime database, stuff it into File::BaseDir::xdg_data_home() ... yeah, real smooth I know