File-LibMagic
view release on metacpan or search on metacpan
Returns the description of a file, just like the `describe_filename` method.
## The "complete" interface
This interface is exported by:
use File::LibMagic ':complete';
This interface exports several subroutines:
- 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 `:complete` import.
my $handle = magic_open(MAGIC_MIME);
- magic\_load($handle, $filename)
This subroutine actually loads the magic file. The `$filename` argument is
optional. There should be a sane default compiled into your `libmagic`
library.
- 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 `magic_open`, a description, a MIME type,
etc.
- magic\_file($handle, $filename)
This returns information about a file as a string. What it returns depends on
the flags you passed to `magic_open`, a description, a MIME type, etc.
- magic\_close($handle)
Closes the magic handle.
# EXCEPTIONS
This module can throw an exception if your system runs out of memory when
trying to call `magic_open` internally.
# 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!
# DEPENDENCIES/PREREQUISITES
This module requires file 4.x or file 5x and the associated libmagic library
and headers (https://darwinsys.com/file/).
# RELATED MODULES
Andreas created File::LibMagic because he wanted to use libmagic (from
file 4.x) [File::MMagic](https://metacpan.org/pod/File%3A%3AMMagic) only worked with file 3.x.
[File::MimeInfo::Magic](https://metacpan.org/pod/File%3A%3AMimeInfo%3A%3AMagic) uses the magic file from freedesktop.org which is
encoded in XML, and is thus not the fastest approach. See
[https://mail.gnome.org/archives/nautilus-list/2003-December/msg00260.html](https://mail.gnome.org/archives/nautilus-list/2003-December/msg00260.html)
for a discussion of this issue.
[File::Type](https://metacpan.org/pod/File%3A%3AType) 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.
# 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 [https://github.com/houseabsolute/File-LibMagic/issues](https://github.com/houseabsolute/File-LibMagic/issues).
I am also usually active on IRC as 'autarch' on `irc://irc.perl.org`.
# SOURCE
The source code repository for File-LibMagic can be found at [https://github.com/houseabsolute/File-LibMagic](https://github.com/houseabsolute/File-LibMagic).
# 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 **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 [https://www.urth.org/fs-donation.html](https://www.urth.org/fs-donation.html).
# AUTHORS
- Andreas Fitzner
- Michael Hendricks <michael@ndrix.org>
- Dave Rolsky <autarch@urth.org>
# CONTRIBUTORS
- E. Choroba <choroba@matfyz.cz>
- Mithun Ayachit <mayachit@amfam.com>
- Olaf Alders <olaf@wundersolutions.com>
- Paul Wise <pabs3@bonedaddy.net>
- Tom Wyant <wyant@cpan.org>
# COPYRIGHT AND LICENSE
This software is copyright (c) 2020 by Andreas Fitzner, Michael Hendricks, Dave Rolsky, and Paul Wise.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
( run in 0.911 second using v1.01-cache-2.11-cpan-e1769b4cff6 )