208 lines
4.5 KiB
HTML
208 lines
4.5 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of File::MimeInfo::Magic</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>File::MimeInfo::Magic</H1>
|
|
Section: User Contributed Perl Documentation (3pm)<BR>Updated: 2018-08-06<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
File::MimeInfo::Magic - Determine file type with magic
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
use File::MimeInfo::Magic;
|
|
my $mime_type = mimetype($file);
|
|
|
|
</PRE>
|
|
|
|
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
|
|
|
|
This module inherits from File::MimeInfo, it is transparent
|
|
to its functions but adds support for the freedesktop magic file.
|
|
<P>
|
|
|
|
Magic data is hashed when you need it for the first time.
|
|
If you want to force hashing earlier use the <TT>"rehash()"</TT> function.
|
|
<A NAME="lbAE"> </A>
|
|
<H2>EXPORT</H2>
|
|
|
|
|
|
|
|
The method <TT>"mimetype"</TT> is exported by default. The methods <TT>"magic"</TT>,
|
|
<TT>"inodetype"</TT>, <TT>"globs"</TT> and <TT>"describe"</TT> can be exported on demand.
|
|
<A NAME="lbAF"> </A>
|
|
<H2>METHODS</H2>
|
|
|
|
|
|
|
|
See also File::MimeInfo for methods that are inherited.
|
|
<DL COMPACT>
|
|
<DT id="1">"mimetype($file)"<DD>
|
|
|
|
|
|
|
|
|
|
Returns a mime-type string for <TT>$file</TT>, returns undef on failure.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
This method bundles <TT>"inodetype()"</TT>, <TT>"globs()"</TT> and <TT>"magic()"</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Magic rules with an priority of 80 and higher are checked before
|
|
<TT>"globs()"</TT> is called, all other magic rules afterwards.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
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 <TT>"undef"</TT> is returned.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
If <TT>$file</TT> is an object reference only <TT>"magic"</TT> and the default method
|
|
are used. See below for details.
|
|
<DT id="2">"magic($file)"<DD>
|
|
|
|
|
|
|
|
|
|
Returns a mime-type string for <TT>$file</TT> based on the magic rules,
|
|
returns undef on failure.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<TT>$file</TT> can be an object reference, in that case it is supposed to have a
|
|
<TT>"seek()"</TT> and a <TT>"read()"</TT> method. This allows you for example to determine
|
|
the mimetype of data in memory by using IO::Scalar.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Be aware that when using a filehandle or an <TT>"IO::"</TT> object you need to set
|
|
the <TT>":utf8"</TT> binmode yourself if appropriate.
|
|
<DT id="3">"rehash()"<DD>
|
|
|
|
|
|
|
|
|
|
Rehash the data files. Glob and magic
|
|
information is preparsed when this method is called.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
If you want to by-pass the <FONT SIZE="-1">XDG</FONT> basedir system you can specify your database
|
|
directories by setting <TT>@File::MimeInfo::DIRS</TT>. But normally it is better to
|
|
change the <FONT SIZE="-1">XDG</FONT> basedir environment variables.
|
|
<DT id="4">"default"<DD>
|
|
|
|
|
|
|
|
|
|
|
|
<DT id="5">"describe"<DD>
|
|
|
|
|
|
|
|
|
|
<DT id="6">"extensions"<DD>
|
|
|
|
|
|
|
|
|
|
<DT id="7">"globs"<DD>
|
|
|
|
|
|
|
|
|
|
<DT id="8">"inodetype"<DD>
|
|
|
|
|
|
|
|
|
|
|
|
These routines are imported from File::MimeInfo.
|
|
</DL>
|
|
<A NAME="lbAG"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
|
|
|
|
File::MimeInfo
|
|
<A NAME="lbAH"> </A>
|
|
<H2>LIMITATIONS</H2>
|
|
|
|
|
|
|
|
Only word sizes of 1, 2 or 4 are supported. Any other word size is ignored
|
|
and will cause a warning.
|
|
<A NAME="lbAI"> </A>
|
|
<H2>AUTHOR</H2>
|
|
|
|
|
|
|
|
Jaap Karssenberg <<A HREF="mailto:pardus@cpan.org">pardus@cpan.org</A>>
|
|
Maintained by Michiel Beijen <<A HREF="mailto:michiel.beijen@gmail.com">michiel.beijen@gmail.com</A>>
|
|
<A NAME="lbAJ"> </A>
|
|
<H2>COPYRIGHT</H2>
|
|
|
|
|
|
|
|
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.
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="9"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="10"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="11"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="12"><A HREF="#lbAE">EXPORT</A><DD>
|
|
<DT id="13"><A HREF="#lbAF">METHODS</A><DD>
|
|
<DT id="14"><A HREF="#lbAG">SEE ALSO</A><DD>
|
|
<DT id="15"><A HREF="#lbAH">LIMITATIONS</A><DD>
|
|
<DT id="16"><A HREF="#lbAI">AUTHOR</A><DD>
|
|
<DT id="17"><A HREF="#lbAJ">COPYRIGHT</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:05:43 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|