NAME
File::Magic - Perl extension for embedding file(1)'s libmagic
SYNOPSIS
use File::Magic;
my $magic => File::Magic->new( [ '/path/to/personal/magic' [, flags ] ] );
my $filetype = $magic->type( File::Spec->catfile( qw(path to file) );
unless( defined( $filetype ) )
{
croak( $magic->errmsg() );
}
print( "$filetype\n" );
DESCRIPTION
This module covers simply getting the file type by using magic_file from libmagic(3) from Ian F. Darwin, Måns Rullgård and Christos Zoulas. The main improvement is no fork(2) is required to get the type of a file and an impressive speed improvement come with that when a lot of files needs to be typed ;-)
EXPORT
None.
FUNCTIONS
- new
-
File::Magic-
new()> instantiates a new object ofFile::Magic
. It creates a new instance within libmagic. Any further calls via this object will have the same magic file and the same flags. - type
-
Returns the "magic" type of the specified file or sprintf( "%s: %s", $filename, strerror( $! ) ); If an internal error within libmagic happens, undef is returned.
- errmsg
-
If - and only if - an error happened within libmagic, the method returns the corrresponding error string.
SEE ALSO
See file(1) and libmagic(3). If your system doesn't contain a compatible file command, see ftp://ftp.astron.com/pub/file/.
AUTHOR
Jens Rehsack <rehsack@web.de>
COPYRIGHT AND LICENSE
Copyright (C) 2008 by Jens Rehsack
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.
2 POD Errors
The following errors were encountered while parsing the POD:
- Around line 90:
Non-ASCII character seen before =encoding in 'Måns'. Assuming CP1252
- Around line 120:
You forgot a '=back' before '=head1'