{"id":7413,"date":"2022-12-20T19:38:00","date_gmt":"2022-12-20T22:38:00","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/filemimeinfomagic-man3\/"},"modified":"2022-12-20T19:38:00","modified_gmt":"2022-12-20T22:38:00","slug":"filemimeinfomagic-man3","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/filemimeinfomagic-man3\/","title":{"rendered":"File::MimeInfo::Magic (man3)"},"content":{"rendered":"<h1 align=\"center\">File::MimeInfo::Magic<\/h1>\n<p> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#EXPORT\">EXPORT<\/a><br \/> <a href=\"#METHODS\">METHODS<\/a><br \/> <a href=\"#SEE ALSO\">SEE ALSO<\/a><br \/> <a href=\"#LIMITATIONS\">LIMITATIONS<\/a><br \/> <a href=\"#AUTHOR\">AUTHOR<\/a><br \/> <a href=\"#COPYRIGHT\">COPYRIGHT<\/a> <\/p>\n<hr>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">File::MimeInfo::Magic \u2212 Determine file type with magic<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">use File::MimeInfo::Magic; <br \/> my $mime_type = mimetype($file);<\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">This module inherits from File::MimeInfo, it is transparent to its functions but adds support for the freedesktop magic file.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Magic data is hashed when you need it for the first time. If you want to force hashing earlier use the &#8220;rehash()&#8221; function.<\/p>\n<h2>EXPORT <a name=\"EXPORT\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The method &#8220;mimetype&#8221; is exported by default. The methods &#8220;magic&#8221;, &#8220;inodetype&#8221;, &#8220;globs&#8221; and &#8220;describe&#8221; can be exported on demand.<\/p>\n<h2>METHODS <a name=\"METHODS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">See also File::MimeInfo for methods that are inherited. <br \/> &#8220;mimetype($file)&#8221;<\/p>\n<p style=\"margin-left:17%;\">Returns a mime-type string for $file, returns undef on failure.<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">This method bundles &#8220;inodetype()&#8221;, &#8220;globs()&#8221; and &#8220;magic()&#8221;.<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">Magic rules with an priority of 80 and higher are checked before &#8220;globs()&#8221; is called, all other magic rules afterwards.<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">If this doesn\u2019t work the file is read and the mime-type defaults to \u2019text\/plain\u2019 or to \u2019application\/octet\u2212stream\u2019 when the first ten chars of the file match ascii control chars (white spaces excluded). If the file doesn\u2019t exist or isn\u2019t readable &#8220;undef&#8221; is returned.<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">If $file is an object reference only &#8220;magic&#8221; and the default method are used. See below for details.<\/p>\n<p style=\"margin-left:11%;\">&#8220;magic($file)&#8221;<\/p>\n<p style=\"margin-left:17%;\">Returns a mime-type string for $file based on the magic rules, returns undef on failure.<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">$file can be an object reference, in that case it is supposed to have a &#8220;seek()&#8221; and a &#8220;read()&#8221; method. This allows you for example to determine the mimetype of data in memory by using IO::Scalar.<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">Be aware that when using a filehandle or an &#8220;IO::&#8221; object you need to set the &#8220;:utf8&#8221; binmode yourself if appropriate.<\/p>\n<p style=\"margin-left:11%;\">&#8220;rehash()&#8221;<\/p>\n<p style=\"margin-left:17%;\">Rehash the data files. Glob and magic information is preparsed when this method is called.<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">If you want to by-pass the <small>XDG<\/small> basedir system you can specify your database directories by setting @File::MimeInfo::DIRS. But normally it is better to change the <small>XDG<\/small> basedir environment variables.<\/p>\n<p style=\"margin-left:11%;\">&#8220;default&#8221; <br \/> &#8220;describe&#8221; <br \/> &#8220;extensions&#8221; <br \/> &#8220;globs&#8221; <br \/> &#8220;inodetype&#8221;<\/p>\n<p style=\"margin-left:17%;\">These routines are imported from File::MimeInfo.<\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">File::MimeInfo<\/p>\n<h2>LIMITATIONS <a name=\"LIMITATIONS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Only word sizes of 1, 2 or 4 are supported. Any other word size is ignored and will cause a warning.<\/p>\n<h2>AUTHOR <a name=\"AUTHOR\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Jaap Karssenberg <pardus@cpan.org> Maintained by Michiel Beijen <michiel.beijen@gmail.com><\/p>\n<h2>COPYRIGHT <a name=\"COPYRIGHT\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">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>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  File::MimeInfo::Magic \u2212 Determine file type with magic <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[3725,3007],"class_list":["post-7413","post","type-post","status-publish","format-standard","hentry","category-sin-categoria","tag-filemimeinfomagic","tag-man3"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/7413","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=7413"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/7413\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=7413"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=7413"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=7413"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}