Document fileinfo

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@208999 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Jakub Vrana 2006-03-09 14:15:41 +00:00
parent 1070105ccb
commit f19a0e6cd2
8 changed files with 728 additions and 0 deletions

View file

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.1 $ -->
<section id="fileinfo.installation">
&reftitle.install;
<para>
A short installation note: just type
<screen>
$ pear install fileinfo
</screen>
in your console.
</para>
</section>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

View file

@ -0,0 +1,119 @@
<?xml version='1.0' encoding='iso-8859-1'?>
<!-- $Revision: 1.1 $ -->
<!-- Generated by xml_proto.php v2.3. Found in /scripts directory of phpdoc. -->
<section id="fileinfo.constants">
&reftitle.constants;
&extension.constants;
<variablelist>
<varlistentry>
<term>
<constant>FILEINFO_NONE</constant>
(<type>integer</type>)
</term>
<listitem>
<simpara>
No special handling.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<constant>FILEINFO_SYMLINK</constant>
(<type>integer</type>)
</term>
<listitem>
<simpara>
Follow symlinks.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<constant>FILEINFO_MIME</constant>
(<type>integer</type>)
</term>
<listitem>
<simpara>
Return a mime string, instead of a textual description.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<constant>FILEINFO_COMPRESS</constant>
(<type>integer</type>)
</term>
<listitem>
<simpara>
Decompress compressed files.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<constant>FILEINFO_DEVICES</constant>
(<type>integer</type>)
</term>
<listitem>
<simpara>
Look at the contents of blocks or character special devices.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<constant>FILEINFO_CONTINUE</constant>
(<type>integer</type>)
</term>
<listitem>
<simpara>
Return all matches, not just the first.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<constant>FILEINFO_PRESERVE_ATIME</constant>
(<type>integer</type>)
</term>
<listitem>
<simpara>
If possible preserve the original access time.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<constant>FILEINFO_RAW</constant>
(<type>integer</type>)
</term>
<listitem>
<simpara>
Don't translate unprintable characters to a <literal>\ooo</literal> octal
representation.
</simpara>
</listitem>
</varlistentry>
</variablelist>
</section>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

View file

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.1 $ -->
<!-- Generated by xml_proto.php v2.3. Found in /scripts directory of phpdoc. -->
<refentry id="function.finfo-buffer">
<refnamediv>
<refname>finfo_buffer</refname>
<refpurpose>Return infromation about a string buffer</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>string</type><methodname>finfo_buffer</methodname>
<methodparam><type>resource</type><parameter>finfo</parameter></methodparam>
<methodparam><type>string</type><parameter>string</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>options</parameter></methodparam>
</methodsynopsis>
<classsynopsis>
<ooclass><classname>finfo</classname></ooclass>
<methodsynopsis>
<type>string</type><methodname>buffer</methodname>
<methodparam><type>string</type><parameter>string</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>options</parameter></methodparam>
</methodsynopsis>
</classsynopsis>
<para>
This function is used to get information about binary data in a string.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>finfo</parameter></term>
<listitem>
<para>
Fileinfo resource returned by <function>finfo_open</function>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>string</parameter></term>
<listitem>
<para>
Content of a file to be checked.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>options</parameter></term>
<listitem>
<para>
One or disjunction of more <link linkend="fileinfo.constants">Fileinfo
constants</link>.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns a textual description of the <parameter>string</parameter>
argument, or &false; if an error occurred.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>A <function>finfo_buffer</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$finfo = new finfo(FILEINFO_MIME);
echo $finfo->buffer($_POST["script"]) . "\n";
?>
]]>
</programlisting>
&example.outputs.similar;
<screen>
<![CDATA[
application/x-sh
]]>
</screen>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>finfo_file</function></member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

View file

@ -0,0 +1,64 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.1 $ -->
<!-- Generated by xml_proto.php v2.3. Found in /scripts directory of phpdoc. -->
<refentry id="function.finfo-close">
<refnamediv>
<refname>finfo_close</refname>
<refpurpose>Close fileinfo resource</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>bool</type><methodname>finfo_close</methodname>
<methodparam><type>resource</type><parameter>finfo</parameter></methodparam>
</methodsynopsis>
<para>
This function closes the resource opened by <function>finfo_open</function>.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>finfo</parameter></term>
<listitem>
<para>
Fileinfo resource returned by <function>finfo_open</function>.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
&return.success;
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

View file

@ -0,0 +1,140 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.1 $ -->
<!-- Generated by xml_proto.php v2.3. Found in /scripts directory of phpdoc. -->
<refentry id="function.finfo-file">
<refnamediv>
<refname>finfo_file</refname>
<refpurpose>Return information about a file</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>string</type><methodname>finfo_file</methodname>
<methodparam><type>resource</type><parameter>finfo</parameter></methodparam>
<methodparam><type>string</type><parameter>file_name</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>options</parameter></methodparam>
<methodparam choice="opt"><type>resource</type><parameter>context</parameter></methodparam>
</methodsynopsis>
<classsynopsis>
<ooclass><classname>finfo</classname></ooclass>
<methodsynopsis>
<type>string</type><methodname>file</methodname>
<methodparam><type>string</type><parameter>file_name</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>options</parameter></methodparam>
<methodparam choice="opt"><type>resource</type><parameter>context</parameter></methodparam>
</methodsynopsis>
</classsynopsis>
<para>
This function is used to get information about a file.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>finfo</parameter></term>
<listitem>
<para>
Fileinfo resource returned by <function>finfo_open</function>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>file_name</parameter></term>
<listitem>
<para>
Name of a file to be checked.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>options</parameter></term>
<listitem>
<para>
One or disjunction of more <link linkend="fileinfo.constants">Fileinfo
constants</link>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>context</parameter></term>
<listitem>
<para>
For a description of <literal>contexts</literal>, refer to <xref
linkend="ref.stream"/>.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns a textual description of the contents of the
<parameter>filename</parameter> argument, or &false; if an error occurred.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>A <function>finfo_file</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$finfo = finfo_open(FILEINFO_MIME); // return mime type ala mimetype extension
foreach (glob("*") as $filename) {
echo finfo_file($finfo, $filename) . "\n";
}
finfo_close($finfo);
?>
]]>
</programlisting>
&example.outputs.similar;
<screen>
<![CDATA[
text/html
image/gif
application/vnd.ms-excel
]]>
</screen>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>finfo_buffer</function></member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

View file

@ -0,0 +1,96 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.1 $ -->
<!-- Generated by xml_proto.php v2.3. Found in /scripts directory of phpdoc. -->
<refentry id="function.finfo-open">
<refnamediv>
<refname>finfo_open</refname>
<refpurpose>Create a new fileinfo resource</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>resource</type><methodname>finfo_open</methodname>
<methodparam choice="opt"><type>int</type><parameter>options</parameter></methodparam>
<methodparam choice="opt"><type>string</type><parameter>arg</parameter></methodparam>
</methodsynopsis>
<classsynopsis>
<ooclass><classname>finfo</classname></ooclass>
<constructorsynopsis>
<methodname>__construct</methodname>
<methodparam choice="opt"><type>int</type><parameter>options</parameter></methodparam>
<methodparam choice="opt"><type>string</type><parameter>magic_file</parameter></methodparam>
</constructorsynopsis>
</classsynopsis>
<para>
This function opens a magic database and returns its resource.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>options</parameter></term>
<listitem>
<para>
One or disjunction of more <link linkend="fileinfo.constants">Fileinfo
constants</link>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>magic_file</parameter></term>
<listitem>
<para>
Name of a magic database file, usually something like
<filename>/path/to/magic.mime</filename>. If not specified,
<literal>MAGIC</literal> environment variable is used. If this variable
is not set neither, <filename>/usr/share/misc/magic</filename> is used.
<literal>.mime</literal> and/or <literal>.mgc</literal> is added if
appropriate.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns a magic database resource on success or &false; on failure.
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>finfo_close</function></member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

View file

@ -0,0 +1,82 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.1 $ -->
<!-- Generated by xml_proto.php v2.3. Found in /scripts directory of phpdoc. -->
<refentry id="function.finfo-set-flags">
<refnamediv>
<refname>finfo_set_flags</refname>
<refpurpose>Set libmagic configuration options</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>bool</type><methodname>finfo_set_flags</methodname>
<methodparam><type>resource</type><parameter>finfo</parameter></methodparam>
<methodparam><type>int</type><parameter>options</parameter></methodparam>
</methodsynopsis>
<classsynopsis>
<ooclass><classname>finfo</classname></ooclass>
<methodsynopsis>
<type>bool</type><methodname>set_flags</methodname>
<methodparam><type>int</type><parameter>options</parameter></methodparam>
</methodsynopsis>
</classsynopsis>
<para>
This function sets various Fileinfo options. Options can be set also
directly in <function>finfo_open</function> or other Fileinfo functions.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>finfo</parameter></term>
<listitem>
<para>
Fileinfo resource returned by <function>finfo_open</function>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>options</parameter></term>
<listitem>
<para>
One or disjunction of more <link linkend="fileinfo.constants">Fileinfo
constants</link>.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
&return.success;
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

View file

@ -0,0 +1,69 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.1 $ -->
<!-- Purpose: fileprocess.file -->
<!-- Membership: pecl -->
<!-- Generated by xml_proto.php v2.3. Found in /scripts directory of phpdoc. -->
<reference id="ref.fileinfo">
<title>Fileinfo Functions</title>
<titleabbrev>Fileinfo</titleabbrev>
<partintro>
<section id="fileinfo.intro">
&reftitle.intro;
<para>
The functions in this module try to guess the content type
and encoding of a file by looking for certain
<emphasis>magic</emphasis> byte sequences at specific
positions within the file. While this is not a bullet proof
approach the heuristics used do a very good job.
</para>
</section>
<section id="fileinfo.requirements">
&reftitle.required;
<para>
<literal>magic_open</literal> library is needed to build this extension.
</para>
</section>
<!-- Information found in configure.xml -->
&reference.fileinfo.configure;
<section id="fileinfo.configuration">
&reftitle.runtime;
&no.config;
</section>
<section id="fileinfo.resources">
&reftitle.resources;
<para>
There is one resource used in Fileinfo extension: a magic database
descriptor returned by <function>finfo_open</function>.
</para>
</section>
<!-- Information found in constants.xml -->
&reference.fileinfo.constants;
</partintro>
&reference.fileinfo.functions;
</reference>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->