File-LibMagic
view release on metacpan or search on metacpan
lib/File/LibMagic.pm view on Meta::CPAN
This interface is exported by:
use File::LibMagic ':complete';
This interface exports several subroutines:
=over 4
=item * magic_open($flags)
This subroutine opens creates a magic handle. See the libmagic man page for a
description of all the flags. These are exported by the C<:complete> import.
my $handle = magic_open(MAGIC_MIME);
=item * magic_load($handle, $filename)
This subroutine actually loads the magic file. The C<$filename> argument is
optional. There should be a sane default compiled into your C<libmagic>
library.
=item * magic_buffer($handle, $data)
This returns information about a chunk of data as a string. What it returns
depends on the flags you passed to C<magic_open>, a description, a MIME type,
etc.
=item * magic_file($handle, $filename)
This returns information about a file as a string. What it returns depends on
the flags you passed to C<magic_open>, a description, a MIME type, etc.
=item * magic_close($handle)
Closes the magic handle.
=back
=head1 EXCEPTIONS
This module can throw an exception if your system runs out of memory when
trying to call C<magic_open> internally.
=head1 BUGS
This module is totally dependent on the version of file on your system. It's
possible that the tests will fail because of this. Please report these
failures so I can make the tests smarter. Please make sure to report the
version of file on your system as well!
=head1 DEPENDENCIES/PREREQUISITES
This module requires file 4.x or file 5x and the associated libmagic library
and headers (https://darwinsys.com/file/).
=head1 RELATED MODULES
Andreas created File::LibMagic because he wanted to use libmagic (from
file 4.x) L<File::MMagic> only worked with file 3.x.
L<File::MimeInfo::Magic> uses the magic file from freedesktop.org which is
encoded in XML, and is thus not the fastest approach. See
L<https://mail.gnome.org/archives/nautilus-list/2003-December/msg00260.html>
for a discussion of this issue.
L<File::Type> uses a relatively small magic file, which is directly hacked
into the module code. It is quite fast but the database is quite small
relative to the file package.
=head1 SUPPORT
Please submit bugs to the CPAN RT system at
https://rt.cpan.org/Public/Dist/Display.html?Name=File-LibMagic or via email at
bug-file-libmagic@rt.cpan.org.
Bugs may be submitted at L<https://github.com/houseabsolute/File-LibMagic/issues>.
I am also usually active on IRC as 'autarch' on C<irc://irc.perl.org>.
=head1 SOURCE
The source code repository for File-LibMagic can be found at L<https://github.com/houseabsolute/File-LibMagic>.
=head1 DONATIONS
If you'd like to thank me for the work I've done on this module, please
consider making a "donation" to me via PayPal. I spend a lot of free time
creating free software, and would appreciate any support you'd care to offer.
Please note that B<I am not suggesting that you must do this> in order for me
to continue working on this particular software. I will continue to do so,
inasmuch as I have in the past, for as long as it interests me.
Similarly, a donation made in this way will probably not make me work on this
software much more, unless I get so many donations that I can consider working
on free software full time (let's all have a chuckle at that together).
To donate, log into PayPal and send money to autarch@urth.org, or use the
button at L<https://www.urth.org/fs-donation.html>.
=head1 AUTHORS
=over 4
=item *
Andreas Fitzner
=item *
Michael Hendricks <michael@ndrix.org>
=item *
Dave Rolsky <autarch@urth.org>
=back
=head1 CONTRIBUTORS
=for stopwords E. Choroba Mithun Ayachit Olaf Alders Paul Wise Tom Wyant
( run in 0.933 second using v1.01-cache-2.11-cpan-e1769b4cff6 )