06 Mar 2022 08:08:08 UTC
- Distribution: File-MimeInfo
- Module version: 0.32
- Source (raw)
- Browse (raw)
- How to Contribute
- Issues (18)
- Testers (681 / 0 / 0)
- KwaliteeBus factor: 1
- 67.69% Coverage
- License: perl_5
- Perl: v5.6.1
- Activity24 month
- Download (36.7KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest version++ed by:5 non-PAUSE usersMICHIELB Michiel Beijenand 19 contributors
- Jaap Karssenberg
- Bernhard RosenkrÃ¤nzer
- Christian Ludwig
- David Steinbrunner
- Jitka Plesnikova
- Jonathan Dowland
- Martin Vassor
- Michiel Beijen
- Nikos Skalkotos
- Nitish Bezzala
- Oleg Kostyuk
- Patrick Burroughs (Celti)
- Philippe Bruhat (BooK)
- Rudolf Leermakers
- Sean Smith
- Stefan Seifert
- brian m. carlson
- gregor herrmann
File::MimeInfo::Magic - Determine file type with magic
use File::MimeInfo::Magic; my $mime_type = mimetype($file);
This module inherits from File::MimeInfo, it is transparent to its functions but adds support for the freedesktop magic file.
Magic data is hashed when you need it for the first time. If you want to force hashing earlier use the
mimetypeis exported by default. The methods
describecan be exported on demand.
See also File::MimeInfo for methods that are inherited.
Returns a mime-type string for
$file, returns undef on failure.
This method bundles
Magic rules with an priority of 80 and higher are checked before
globs()is called, all other magic rules afterwards.
If this doesn't work the file is read and the mime-type defaults to 'text/plain' or to 'application/octet-stream' when the first ten chars of the file match ascii control chars (white spaces excluded). If the file doesn't exist or isn't readable
$fileis an object reference only
magicand the default method are used. See below for details.
Returns a mime-type string for
$filebased on the magic rules, returns undef on failure.
$filecan be an object reference, in that case it is supposed to have a
read()method. This allows you for example to determine the mimetype of data in memory by using IO::Scalar.
Be aware that when using a filehandle or an
IO::object you need to set the
:utf8binmode yourself if appropriate.
Rehash the data files. Glob and magic information is preparsed when this method is called.
If you want to by-pass the XDG basedir system you can specify your database directories by setting
@File::MimeInfo::DIRS. But normally it is better to change the XDG basedir environment variables.
These routines are imported from File::MimeInfo.
Only word sizes of 1, 2 or 4 are supported. Any other word size is ignored and will cause a warning.
Jaap Karssenberg <email@example.com> Maintained by Michiel Beijen <firstname.lastname@example.org>
Copyright (c) 2003, 2012 Jaap G Karssenberg. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Module Install Instructions
To install File::MimeInfo, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell install File::MimeInfo
For more information on module installation, please visit the detailed CPAN module installation guide.