<refentry id="gnome-vfs-20-gnome-vfs-mime">
<refmeta>
<refentrytitle id="top_of_page">MIME typing</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>GNOME-VFS-2.0 Library</refmiscinfo>
</refmeta>

<refnamediv>
<refname>MIME typing</refname>
<refpurpose>functions to get a mime-type for a file using its name or its content</refpurpose>
<!--[<xref linkend="desc" endterm="desc.title"/>]-->
</refnamediv>

<refsynopsisdiv id="synopsis">
<title id="synopsis.title">Synopsis</title>

<synopsis>



<link linkend="void">void</link>        <link linkend="gnome-vfs-mime-shutdown">gnome_vfs_mime_shutdown</link>         (void);
const <link linkend="char">char</link>* <link linkend="gnome-vfs-mime-type-from-name">gnome_vfs_mime_type_from_name</link>   (const <link linkend="char">char</link> *filename);
const <link linkend="char">char</link>* <link linkend="gnome-vfs-mime-type-from-name-or-default">gnome_vfs_mime_type_from_name_or_default</link>
                                            (const <link linkend="char">char</link> *filename,
                                             const <link linkend="char">char</link> *defaultv);
const <link linkend="char">char</link>* <link linkend="gnome-vfs-get-mime-type-common">gnome_vfs_get_mime_type_common</link>  (<link linkend="GnomeVFSURI">GnomeVFSURI</link> *uri);
const <link linkend="char">char</link>* <link linkend="gnome-vfs-get-mime-type-from-uri">gnome_vfs_get_mime_type_from_uri</link>
                                            (<link linkend="GnomeVFSURI">GnomeVFSURI</link> *uri);
const <link linkend="char">char</link>* <link linkend="gnome-vfs-get-mime-type-from-file-data">gnome_vfs_get_mime_type_from_file_data</link>
                                            (<link linkend="GnomeVFSURI">GnomeVFSURI</link> *uri);
const <link linkend="char">char</link>* <link linkend="gnome-vfs-get-file-mime-type">gnome_vfs_get_file_mime_type</link>    (const <link linkend="char">char</link> *path,
                                             const struct <link linkend="stat">stat</link> *optional_stat_info,
                                             <link linkend="gboolean">gboolean</link> suffix_only);
<link linkend="gboolean">gboolean</link>    <link linkend="gnome-vfs-mime-type-is-supertype">gnome_vfs_mime_type_is_supertype</link>
                                            (const <link linkend="char">char</link> *mime_type);
<link linkend="char">char</link>*       <link linkend="gnome-vfs-get-supertype-from-mime-type">gnome_vfs_get_supertype_from_mime_type</link>
                                            (const <link linkend="char">char</link> *mime_type);
</synopsis>
</refsynopsisdiv>









<refsect1 id="desc">
<title id="desc.title">Description</title>
<para>

</para>
</refsect1>

<refsect1 id="details">
<title id="details.title">Details</title>
<refsect2>
<title><anchor id="gnome-vfs-mime-shutdown" role="function" condition="deprecated"/>gnome_vfs_mime_shutdown ()</title>
<indexterm role="deprecated"><primary>gnome_vfs_mime_shutdown</primary></indexterm><programlisting><link linkend="void">void</link>        gnome_vfs_mime_shutdown         (void);</programlisting>
<warning><para><literal>gnome_vfs_mime_shutdown</literal> is deprecated and should not be used in newly-written code. This function doesn't have to be called as the
operating system automatically cleans up resources when exiting.
</para>
<para>
Unload the MIME database from memory.</para></warning>
<para>
</para>
<para>

</para></refsect2>
<refsect2>
<title><anchor id="gnome-vfs-mime-type-from-name" role="function" condition="deprecated"/>gnome_vfs_mime_type_from_name ()</title>
<indexterm role="deprecated"><primary>gnome_vfs_mime_type_from_name</primary></indexterm><programlisting>const <link linkend="char">char</link>* gnome_vfs_mime_type_from_name   (const <link linkend="char">char</link> *filename);</programlisting>
<warning><para><literal>gnome_vfs_mime_type_from_name</literal> is deprecated and should not be used in newly-written code. This function is deprecated, use
gnome_vfs_get_mime_type_for_name instead.</para></warning>
<para>
Determine the mime type for <parameter>filename</parameter>.
</para>
<para>
Returns:</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>filename</parameter>&nbsp;:</term>
<listitem><simpara> a filename (the file does not necessarily exist).
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> the mime-type for this filename. Will return
<literal>GNOME_VFS_MIME_TYPE_UNKNOWN</literal> if mime-type could not be found.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="gnome-vfs-mime-type-from-name-or-default" role="function"/>gnome_vfs_mime_type_from_name_or_default ()</title>
<indexterm><primary>gnome_vfs_mime_type_from_name_or_default</primary></indexterm><programlisting>const <link linkend="char">char</link>* gnome_vfs_mime_type_from_name_or_default
                                            (const <link linkend="char">char</link> *filename,
                                             const <link linkend="char">char</link> *defaultv);</programlisting>
<para>
This routine tries to determine the mime-type of the filename
only by looking at the filename from the GNOME database of mime-types.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>filename</parameter>&nbsp;:</term>
<listitem><simpara> a filename (the file does not necessarily exist).
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>defaultv</parameter>&nbsp;:</term>
<listitem><simpara> a default value to be returned if no match is found.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> the mime-type of the <parameter>filename</parameter>.  If no value could be
determined, it will return <parameter>defaultv</parameter>.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="gnome-vfs-get-mime-type-common" role="function"/>gnome_vfs_get_mime_type_common ()</title>
<indexterm><primary>gnome_vfs_get_mime_type_common</primary></indexterm><programlisting>const <link linkend="char">char</link>* gnome_vfs_get_mime_type_common  (<link linkend="GnomeVFSURI">GnomeVFSURI</link> *uri);</programlisting>
<para>
Tries to guess the mime type of the file represented by <parameter>uri</parameter>.
Favors using the file data to the <parameter>uri</parameter> extension.
Handles <parameter>uri</parameter> of a non-existent file by falling back
on returning a type based on the extension. If cant find the mime-type based on the 
extension also then returns 'application/octet-stream'.
</para>
<para>
FIXME: This function will not necessarily return the same mime type as doing a
get file info on the text uri.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>uri</parameter>&nbsp;:</term>
<listitem><simpara> a real file or a non-existent uri.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> the mime-type for <parameter>uri</parameter>.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="gnome-vfs-get-mime-type-from-uri" role="function"/>gnome_vfs_get_mime_type_from_uri ()</title>
<indexterm><primary>gnome_vfs_get_mime_type_from_uri</primary></indexterm><programlisting>const <link linkend="char">char</link>* gnome_vfs_get_mime_type_from_uri
                                            (<link linkend="GnomeVFSURI">GnomeVFSURI</link> *uri);</programlisting>
<para>
Tries to guess the mime type of the file <parameter>uri</parameter> by
checking the file name extension. Works on non-existent
files.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>uri</parameter>&nbsp;:</term>
<listitem><simpara> a file uri.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> the mime-type for file at <parameter>uri</parameter>.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="gnome-vfs-get-mime-type-from-file-data" role="function" condition="deprecated:"/>gnome_vfs_get_mime_type_from_file_data ()</title>
<indexterm role="deprecated"><primary>gnome_vfs_get_mime_type_from_file_data</primary></indexterm><programlisting>const <link linkend="char">char</link>* gnome_vfs_get_mime_type_from_file_data
                                            (<link linkend="GnomeVFSURI">GnomeVFSURI</link> *uri);</programlisting>
<warning><para><literal>gnome_vfs_get_mime_type_from_file_data</literal> is deprecated and should not be used in newly-written code. </para></warning>
<para>
Tries to guess the mime type of the file <parameter>uri</parameter> by
checking the file data using the magic patterns. Does not handle text files properly.
</para>
<para>
Returns:</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>uri</parameter>&nbsp;:</term>
<listitem><simpara> a file uri.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> the mime-type for this filename.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="gnome-vfs-get-file-mime-type" role="function"/>gnome_vfs_get_file_mime_type ()</title>
<indexterm><primary>gnome_vfs_get_file_mime_type</primary></indexterm><programlisting>const <link linkend="char">char</link>* gnome_vfs_get_file_mime_type    (const <link linkend="char">char</link> *path,
                                             const struct <link linkend="stat">stat</link> *optional_stat_info,
                                             <link linkend="gboolean">gboolean</link> suffix_only);</programlisting>
<para>
Tries to guess the mime type of the file represented by <parameter>path</parameter>.
If <parameter>suffix_only</parameter> is false, uses the mime-magic based lookup first.
Handles <parameter>path</parameter> of a non-existent file by falling back
on returning a type based on the extension.
</para>
<para>
If you need a faster, less accurate version, use
<link linkend="gnome-vfs-get-file-mime-type-fast"><function>gnome_vfs_get_file_mime_type_fast()</function></link>.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>path</parameter>&nbsp;:</term>
<listitem><simpara> path of a file whose mime type is to be found out.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>optional_stat_info</parameter>&nbsp;:</term>
<listitem><simpara> optional stat buffer.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>suffix_only</parameter>&nbsp;:</term>
<listitem><simpara> whether or not to do a magic-based lookup.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> the mime-type for file at <parameter>path</parameter>.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="gnome-vfs-mime-type-is-supertype" role="function"/>gnome_vfs_mime_type_is_supertype ()</title>
<indexterm><primary>gnome_vfs_mime_type_is_supertype</primary></indexterm><programlisting><link linkend="gboolean">gboolean</link>    gnome_vfs_mime_type_is_supertype
                                            (const <link linkend="char">char</link> *mime_type);</programlisting>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>mime_type</parameter>&nbsp;:</term>
<listitem><simpara>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara>


</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="gnome-vfs-get-supertype-from-mime-type" role="function"/>gnome_vfs_get_supertype_from_mime_type ()</title>
<indexterm><primary>gnome_vfs_get_supertype_from_mime_type</primary></indexterm><programlisting><link linkend="char">char</link>*       gnome_vfs_get_supertype_from_mime_type
                                            (const <link linkend="char">char</link> *mime_type);</programlisting>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>mime_type</parameter>&nbsp;:</term>
<listitem><simpara>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara>


</simpara></listitem></varlistentry>
</variablelist></refsect2>

</refsect1>




</refentry>
