| 1 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" |
| 2 |
"http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd"> |
| 3 |
<html xmlns="http://www.w3.org/1999/xhtml"> |
| 4 |
<head> |
| 5 |
<title>File::Type - determine file type using magic</title> |
| 6 |
<link rev="made" href="mailto:[email protected]" /> |
| 7 |
</head> |
| 8 |
|
| 9 |
<body style="background-color: white"> |
| 10 |
|
| 11 |
<p><a name="__index__"></a></p> |
| 12 |
|
| 13 |
|
| 14 |
<ul> |
| 15 |
|
| 16 |
<li><a href="#name">NAME</a></li> |
| 17 |
<li><a href="#synopsis">SYNOPSIS</a></li> |
| 18 |
<li><a href="#description">DESCRIPTION</a></li> |
| 19 |
<li><a href="#methods">METHODS</a></li> |
| 20 |
<ul> |
| 21 |
|
| 22 |
<li><a href="#new">new</a></li> |
| 23 |
<li><a href="#checktype_filename__filename_"><code>checktype_filename($filename)</code></a></li> |
| 24 |
<li><a href="#checktype_contents__data_"><code>checktype_contents($data)</code></a></li> |
| 25 |
</ul> |
| 26 |
|
| 27 |
<li><a href="#todo">TODO</a></li> |
| 28 |
<li><a href="#bugs">BUGS</a></li> |
| 29 |
<ul> |
| 30 |
|
| 31 |
<li><a href="#notes">NOTES</a></li> |
| 32 |
</ul> |
| 33 |
|
| 34 |
<li><a href="#author">AUTHOR</a></li> |
| 35 |
<li><a href="#see_also">SEE ALSO</a></li> |
| 36 |
<li><a href="#licence">LICENCE</a></li> |
| 37 |
<li><a href="#cvs">CVS</a></li> |
| 38 |
</ul> |
| 39 |
|
| 40 |
|
| 41 |
<hr /> |
| 42 |
<p> |
| 43 |
</p> |
| 44 |
<h1><a name="name">NAME</a></h1> |
| 45 |
<p>File::Type - determine file type using magic</p> |
| 46 |
<p> |
| 47 |
</p> |
| 48 |
<hr /> |
| 49 |
<h1><a name="synopsis">SYNOPSIS</a></h1> |
| 50 |
<p>my $ft = File::Type->new();</p> |
| 51 |
<p># read in data from file to $data, then |
| 52 |
my $type_from_data = $ft->checktype_data($data);</p> |
| 53 |
<p># alternatively, check file from disk |
| 54 |
my $type_from_file = $ft->checktype_filename($file);</p> |
| 55 |
<p> |
| 56 |
</p> |
| 57 |
<hr /> |
| 58 |
<h1><a name="description">DESCRIPTION</a></h1> |
| 59 |
<p>File::Type uses magic numbers (typically at the start of a file) to |
| 60 |
determine the MIME type of that file.</p> |
| 61 |
<p>File::Type can use either a filename, or file contents, to determine the |
| 62 |
type of a file.</p> |
| 63 |
<p> |
| 64 |
</p> |
| 65 |
<hr /> |
| 66 |
<h1><a name="methods">METHODS</a></h1> |
| 67 |
<p> |
| 68 |
</p> |
| 69 |
<h2><a name="new">new</a></h2> |
| 70 |
<p>Returns a new File::Type object.</p> |
| 71 |
<p> |
| 72 |
</p> |
| 73 |
<h2><a name="checktype_filename__filename_"><code>checktype_filename($filename)</code></a></h2> |
| 74 |
<p>Opens $filename (if possible) and returns the MIME type of the file.</p> |
| 75 |
<p> |
| 76 |
</p> |
| 77 |
<h2><a name="checktype_contents__data_"><code>checktype_contents($data)</code></a></h2> |
| 78 |
<p>Matches $data against the magic database criteria and returns the MIME |
| 79 |
type of the file.</p> |
| 80 |
<p> |
| 81 |
</p> |
| 82 |
<hr /> |
| 83 |
<h1><a name="todo">TODO</a></h1> |
| 84 |
<p>* Add additional magic match criteria</p> |
| 85 |
<p>* Automatically find mime type whether passed data or a filename.</p> |
| 86 |
<p> |
| 87 |
</p> |
| 88 |
<hr /> |
| 89 |
<h1><a name="bugs">BUGS</a></h1> |
| 90 |
<p>None known.</p> |
| 91 |
<p> |
| 92 |
</p> |
| 93 |
<h2><a name="notes">NOTES</a></h2> |
| 94 |
<p>Some magic definitions in the mime-magic file vary from those in other apps |
| 95 |
(eg image/x-png not image/png).</p> |
| 96 |
<p> |
| 97 |
</p> |
| 98 |
<hr /> |
| 99 |
<h1><a name="author">AUTHOR</a></h1> |
| 100 |
<p>Paul Mison <<a href="mailto:[email protected]">[email protected]</a>></p> |
| 101 |
<p> |
| 102 |
</p> |
| 103 |
<hr /> |
| 104 |
<h1><a name="see_also">SEE ALSO</a></h1> |
| 105 |
<p><a href="/File/MMagic.html">the File::MMagic manpage</a> and <a href="/File/MimeInfo.html">the File::MimeInfo manpage</a> do the same job, but parse the magic file |
| 106 |
at runtime, rather than compiling it into code beforehand.</p> |
| 107 |
<p><a href="/File/Type/Builder.html">the File::Type::Builder manpage</a>, which generates the code at the heart of this module.</p> |
| 108 |
<p> |
| 109 |
</p> |
| 110 |
<hr /> |
| 111 |
<h1><a name="licence">LICENCE</a></h1> |
| 112 |
<p>This module is released under the same terms as Perl itself.</p> |
| 113 |
<p> |
| 114 |
</p> |
| 115 |
<hr /> |
| 116 |
<h1><a name="cvs">CVS</a></h1> |
| 117 |
<p>$Header: /usr/local/repository/Vendor/Fotango/File-Type/t/files/File-Type.html,v 1.1 2003/08/22 15:43:23 paul Exp $</p> |
| 118 |
|
| 119 |
</body> |
| 120 |
|
| 121 |
</html> |