<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <link rel="stylesheet" href="style.css" type="text/css"> <meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type"> <link rel="Start" href="index.html"> <link rel="Up" href="index.html"> <link title="Index of types" rel=Appendix href="index_types.html"> <link title="Index of exceptions" rel=Appendix href="index_exceptions.html"> <link title="Index of values" rel=Appendix href="index_values.html"> <link title="Index of modules" rel=Appendix href="index_modules.html"> <link title="Magic" rel="Chapter" href="Magic.html"><title>Magic</title> </head> <body> <div class="navbar"> <a href="index.html">Up</a> </div> <center><h1>Module <a href="type_Magic.html">Magic</a></h1></center> <br> <pre><span class="keyword">module</span> Magic: <code class="code">sig</code> <a href="Magic.html">..</a> <code class="code">end</code></pre>Try to identify the type of file using some "magic number" tests.<br> <b>Author(s):</b> Christophe Troestler <chris_77@users.sourceforge.net><br> <b>Version:</b> 0.7.3<br> <hr width="100%"> <pre><span class="keyword">type</span> <a name="TYPEt"></a><code class="type"></code>t </pre> <div class="info"> Magic "cookies".<br> </div> <pre><span class="keyword">exception</span> <a name="EXCEPTIONFailure"></a>Failure <span class="keyword">of</span> <code class="type">string</code></pre> <div class="info"> Raised by the functions of this library when they fail. The string is an explanation of why the failure happened.<br> </div> <br><code><span class="keyword">type</span> <a name="TYPEflag"></a><code class="type"></code>flag = </code><table class="typetable"> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span class="constructor">Symlink</span></code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >If the file queried is a symlink, follow it.</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span class="constructor">Compress</span></code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >If the file is compressed, unpack it and look at the contents.</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span class="constructor">Devices</span></code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >If the file is a block or character special device, then open the device and try to look in its contents.</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span class="constructor">Mime</span></code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >Return a mime string, instead of a textual description.</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span class="constructor">Continue</span></code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >Return all matches, not just the first.</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span class="constructor">Check</span></code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >Check the magic database for consistency and print warnings to stderr.</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span class="constructor">Preserve_atime</span></code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >On systems that support utime(2) or utimes(2), attempt to preserve the access time of files analyzed.</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span class="constructor">Raw</span></code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >Don't translate unprintable characters to a \ooo octal representation.</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr></table> <pre><span class="keyword">val</span> <a name="VALmake"></a>make : <code class="type">?flags:<a href="Magic.html#TYPEflag">flag</a> list -> string list -> <a href="Magic.html#TYPEt">t</a></code></pre><div class="info"> <code class="code">make ?flags filenames</code> creates a magic cookie, loading the databases in <code class="code">filenames</code>. If <code class="code">filenames = []</code>, the default database is used.<br> <b>Raises</b><ul><li><code>Magic.Failure</code> if there was an error allocating the magic cookie.</li> <li><code>Sys_error</code> if there was an operating system error.</li> </ul> </div> <div class="param_info"><code class="code">flags</code> : specifies how the other magic functions should behave (default: <code class="code">[]</code>).</div> <pre><span class="keyword">val</span> <a name="VALcreate"></a>create : <code class="type">?flags:<a href="Magic.html#TYPEflag">flag</a> list -> string list -> <a href="Magic.html#TYPEt">t</a></code></pre><div class="info"> <span class="warning">Deprecated.</span>Synonym for <a href="Magic.html#VALmake"><code class="code">Magic.make</code></a>.<br> </div> <pre><span class="keyword">val</span> <a name="VALclose"></a>close : <code class="type"><a href="Magic.html#TYPEt">t</a> -> unit</code></pre><div class="info"> <code class="code">close cookie</code> frees the resources associated with the cookie <code class="code">c</code>. You need not to close cookies as the resources will be freed by the garbage collector anyway.<br> </div> <pre><span class="keyword">val</span> <a name="VALfile"></a>file : <code class="type"><a href="Magic.html#TYPEt">t</a> -> string -> string</code></pre><div class="info"> <code class="code">file cookie filename</code> returns a textual description of the contents of the filename argument.<br> <b>Raises</b><ul><li><code>Magic.Failure</code> if an error occurred.</li> <li><code>Invalid_argument</code> if the cookie is closed.</li> <li><code>Sys_error</code> if there was an operating system error.</li> </ul> </div> <pre><span class="keyword">val</span> <a name="VALbuffer"></a>buffer : <code class="type"><a href="Magic.html#TYPEt">t</a> -> ?len:int -> string -> string</code></pre><div class="info"> <code class="code">file cookie ?len buf</code> returns a textual description of the contents of the filename argument.<br> <b>Raises</b><ul><li><code>Magic.Failure</code> if an error occurred.</li> <li><code>Invalid_argument</code> if <code class="code">cookie</code> is closed or if one does not have <code class="code">0 <= len <= String.length buf</code>.</li> </ul> </div> <pre><span class="keyword">val</span> <a name="VALsetflags"></a>setflags : <code class="type"><a href="Magic.html#TYPEt">t</a> -> <a href="Magic.html#TYPEflag">flag</a> list -> unit</code></pre><div class="info"> <code class="code">setflags cookie flags</code> specifies how the other magic functions should behave.<br> <b>Raises</b><ul><li><code>Magic.Failure</code> if the <a href="Magic.html#TYPEflag"><code class="code">Magic.flag</code></a> <code class="code">Preserve_atime</code> is not supported by the operating system.</li> <li><code>Invalid_argument</code> if the cookie has been closed.</li> </ul> </div> <pre><span class="keyword">val</span> <a name="VALload"></a>load : <code class="type"><a href="Magic.html#TYPEt">t</a> -> string list -> unit</code></pre><div class="info"> <code class="code">load cookie filenames</code> loads the the list of database files <code class="code">filenames</code>, or [] for the default database file.<br> <b>Raises</b><ul><li><code>Invalid_argument</code> if the cookie has been closed.</li> <li><code>Sys_error</code> if there was an operating system error.</li> </ul> </div> <pre><span class="keyword">val</span> <a name="VALcompile"></a>compile : <code class="type"><a href="Magic.html#TYPEt">t</a> -> string list -> unit</code></pre><div class="info"> <code class="code">compile cookie filenames</code> compiles the the list of database files <code class="code">filenames</code>, or [] for the default database. The compiled files created are named from the basename(1) of each file argument with ".mgc" appended to it.<br> <b>Raises</b><ul><li><code>Invalid_argument</code> if the cookie has been closed.</li> <li><code>Sys_error</code> if there was an operating system error.</li> </ul> </div> <pre><span class="keyword">val</span> <a name="VALcheck"></a>check : <code class="type"><a href="Magic.html#TYPEt">t</a> -> string list -> bool</code></pre><div class="info"> <code class="code">check cookie filenames</code> checks the validity of entries in the database files <code class="code">filenames</code>, or [] for the default database.<br> <b>Raises</b> <code>Invalid_argument</code> if the cookie has been closed.<br> </div> </body></html>