1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <title>GContentType</title>
6 <meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
7 <link rel="home" href="index.html" title="GIO Reference Manual">
8 <link rel="up" href="types.html" title="File types and applications">
9 <link rel="prev" href="types.html" title="File types and applications">
10 <link rel="next" href="GAppInfo.html" title="GAppInfo">
11 <meta name="generator" content="GTK-Doc V1.18 (XML mode)">
12 <link rel="stylesheet" href="style.css" type="text/css">
14 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
15 <table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
17 <td><a accesskey="p" href="types.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
18 <td><a accesskey="u" href="types.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
19 <td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
20 <th width="100%" align="center">GIO Reference Manual</th>
21 <td><a accesskey="n" href="GAppInfo.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
23 <tr><td colspan="5" class="shortcuts">
24 <a href="#gio-GContentType.synopsis" class="shortcut">Top</a>
26 <a href="#gio-GContentType.description" class="shortcut">Description</a>
29 <div class="refentry">
30 <a name="gio-GContentType"></a><div class="titlepage"></div>
31 <div class="refnamediv"><table width="100%"><tr>
33 <h2><span class="refentrytitle"><a name="gio-GContentType.top_of_page"></a>GContentType</span></h2>
34 <p>GContentType — Platform-specific content typing</p>
36 <td valign="top" align="right"></td>
38 <div class="refsynopsisdiv">
39 <a name="gio-GContentType.synopsis"></a><h2>Synopsis</h2>
40 <pre class="synopsis">
41 #include <gio/gio.h>
43 <a href="./../glib/glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> <a class="link" href="gio-GContentType.html#g-content-type-equals" title="g_content_type_equals ()">g_content_type_equals</a> (<em class="parameter"><code>const <a href="./../glib/glib/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *type1</code></em>,
44 <em class="parameter"><code>const <a href="./../glib/glib/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *type2</code></em>);
45 <a href="./../glib/glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> <a class="link" href="gio-GContentType.html#g-content-type-is-a" title="g_content_type_is_a ()">g_content_type_is_a</a> (<em class="parameter"><code>const <a href="./../glib/glib/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *type</code></em>,
46 <em class="parameter"><code>const <a href="./../glib/glib/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *supertype</code></em>);
47 <a href="./../glib/glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> <a class="link" href="gio-GContentType.html#g-content-type-is-unknown" title="g_content_type_is_unknown ()">g_content_type_is_unknown</a> (<em class="parameter"><code>const <a href="./../glib/glib/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *type</code></em>);
48 <a href="./../glib/glib/glib-Basic-Types.html#gchar"><span class="returnvalue">gchar</span></a> * <a class="link" href="gio-GContentType.html#g-content-type-get-description" title="g_content_type_get_description ()">g_content_type_get_description</a> (<em class="parameter"><code>const <a href="./../glib/glib/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *type</code></em>);
49 <a href="./../glib/glib/glib-Basic-Types.html#gchar"><span class="returnvalue">gchar</span></a> * <a class="link" href="gio-GContentType.html#g-content-type-get-mime-type" title="g_content_type_get_mime_type ()">g_content_type_get_mime_type</a> (<em class="parameter"><code>const <a href="./../glib/glib/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *type</code></em>);
50 <a class="link" href="GIcon.html" title="GIcon"><span class="returnvalue">GIcon</span></a> * <a class="link" href="gio-GContentType.html#g-content-type-get-icon" title="g_content_type_get_icon ()">g_content_type_get_icon</a> (<em class="parameter"><code>const <a href="./../glib/glib/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *type</code></em>);
51 <a href="./../glib/glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> <a class="link" href="gio-GContentType.html#g-content-type-can-be-executable" title="g_content_type_can_be_executable ()">g_content_type_can_be_executable</a> (<em class="parameter"><code>const <a href="./../glib/glib/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *type</code></em>);
52 <a href="./../glib/glib/glib-Basic-Types.html#gchar"><span class="returnvalue">gchar</span></a> * <a class="link" href="gio-GContentType.html#g-content-type-from-mime-type" title="g_content_type_from_mime_type ()">g_content_type_from_mime_type</a> (<em class="parameter"><code>const <a href="./../glib/glib/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *mime_type</code></em>);
53 <a href="./../glib/glib/glib-Basic-Types.html#gchar"><span class="returnvalue">gchar</span></a> * <a class="link" href="gio-GContentType.html#g-content-type-guess" title="g_content_type_guess ()">g_content_type_guess</a> (<em class="parameter"><code>const <a href="./../glib/glib/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *filename</code></em>,
54 <em class="parameter"><code>const <a href="./../glib/glib/glib-Basic-Types.html#guchar"><span class="type">guchar</span></a> *data</code></em>,
55 <em class="parameter"><code><a href="./../glib/glib/glib-Basic-Types.html#gsize"><span class="type">gsize</span></a> data_size</code></em>,
56 <em class="parameter"><code><a href="./../glib/glib/glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a> *result_uncertain</code></em>);
57 <a href="./../glib/glib/glib-Basic-Types.html#gchar"><span class="returnvalue">gchar</span></a> ** <a class="link" href="gio-GContentType.html#g-content-type-guess-for-tree" title="g_content_type_guess_for_tree ()">g_content_type_guess_for_tree</a> (<em class="parameter"><code><a class="link" href="GFile.html" title="GFile"><span class="type">GFile</span></a> *root</code></em>);
58 <a href="./../glib/glib/glib-Doubly-Linked-Lists.html#GList"><span class="returnvalue">GList</span></a> * <a class="link" href="gio-GContentType.html#g-content-types-get-registered" title="g_content_types_get_registered ()">g_content_types_get_registered</a> (<em class="parameter"><code><span class="type">void</span></code></em>);
61 <div class="refsect1">
62 <a name="gio-GContentType.description"></a><h2>Description</h2>
64 A content type is a platform specific string that defines the type
65 of a file. On UNIX it is a <a class="ulink" href="http://www.wikipedia.org/wiki/Internet_media_type" target="_top">mime type</a> like "text/plain" or "image/png".
66 On Win32 it is an extension string like ".doc", ".txt" or a perceived
67 string like "audio". Such strings can be looked up in the registry at
71 <div class="refsect1">
72 <a name="gio-GContentType.details"></a><h2>Details</h2>
73 <div class="refsect2">
74 <a name="g-content-type-equals"></a><h3>g_content_type_equals ()</h3>
75 <pre class="programlisting"><a href="./../glib/glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> g_content_type_equals (<em class="parameter"><code>const <a href="./../glib/glib/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *type1</code></em>,
76 <em class="parameter"><code>const <a href="./../glib/glib/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *type2</code></em>);</pre>
78 Compares two content types for equality.
80 <div class="variablelist"><table border="0">
81 <col align="left" valign="top">
84 <td><p><span class="term"><em class="parameter"><code>type1</code></em> :</span></p></td>
85 <td>a content type string</td>
88 <td><p><span class="term"><em class="parameter"><code>type2</code></em> :</span></p></td>
89 <td>a content type string</td>
92 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
94 <a href="./../glib/glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if the two strings are identical or equivalent,
95 <a href="./../glib/glib/glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> otherwise.</td>
101 <div class="refsect2">
102 <a name="g-content-type-is-a"></a><h3>g_content_type_is_a ()</h3>
103 <pre class="programlisting"><a href="./../glib/glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> g_content_type_is_a (<em class="parameter"><code>const <a href="./../glib/glib/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *type</code></em>,
104 <em class="parameter"><code>const <a href="./../glib/glib/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *supertype</code></em>);</pre>
106 Determines if <em class="parameter"><code>type</code></em> is a subset of <em class="parameter"><code>supertype</code></em>.
108 <div class="variablelist"><table border="0">
109 <col align="left" valign="top">
112 <td><p><span class="term"><em class="parameter"><code>type</code></em> :</span></p></td>
113 <td>a content type string</td>
116 <td><p><span class="term"><em class="parameter"><code>supertype</code></em> :</span></p></td>
117 <td>a content type string</td>
120 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
122 <a href="./../glib/glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if <em class="parameter"><code>type</code></em> is a kind of <em class="parameter"><code>supertype</code></em>,
123 <a href="./../glib/glib/glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> otherwise.</td>
129 <div class="refsect2">
130 <a name="g-content-type-is-unknown"></a><h3>g_content_type_is_unknown ()</h3>
131 <pre class="programlisting"><a href="./../glib/glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> g_content_type_is_unknown (<em class="parameter"><code>const <a href="./../glib/glib/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *type</code></em>);</pre>
133 Checks if the content type is the generic "unknown" type.
134 On UNIX this is the "application/octet-stream" mimetype,
135 while on win32 it is "*".
137 <div class="variablelist"><table border="0">
138 <col align="left" valign="top">
141 <td><p><span class="term"><em class="parameter"><code>type</code></em> :</span></p></td>
142 <td>a content type string</td>
145 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
147 <a href="./../glib/glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if the type is the unknown type.</td>
153 <div class="refsect2">
154 <a name="g-content-type-get-description"></a><h3>g_content_type_get_description ()</h3>
155 <pre class="programlisting"><a href="./../glib/glib/glib-Basic-Types.html#gchar"><span class="returnvalue">gchar</span></a> * g_content_type_get_description (<em class="parameter"><code>const <a href="./../glib/glib/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *type</code></em>);</pre>
157 Gets the human readable description of the content type.
159 <div class="variablelist"><table border="0">
160 <col align="left" valign="top">
163 <td><p><span class="term"><em class="parameter"><code>type</code></em> :</span></p></td>
164 <td>a content type string</td>
167 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
168 <td>a short description of the content type <em class="parameter"><code>type</code></em>. Free the
169 returned string with <a href="./../glib/glib/glib-Memory-Allocation.html#g-free"><code class="function">g_free()</code></a>
176 <div class="refsect2">
177 <a name="g-content-type-get-mime-type"></a><h3>g_content_type_get_mime_type ()</h3>
178 <pre class="programlisting"><a href="./../glib/glib/glib-Basic-Types.html#gchar"><span class="returnvalue">gchar</span></a> * g_content_type_get_mime_type (<em class="parameter"><code>const <a href="./../glib/glib/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *type</code></em>);</pre>
180 Gets the mime type for the content type, if one is registered.
182 <div class="variablelist"><table border="0">
183 <col align="left" valign="top">
186 <td><p><span class="term"><em class="parameter"><code>type</code></em> :</span></p></td>
187 <td>a content type string</td>
190 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
191 <td>the registered mime type for the given <em class="parameter"><code>type</code></em>,
192 or <a href="./../glib/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> if unknown. <span class="annotation">[<acronym title="NULL is ok, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span>
199 <div class="refsect2">
200 <a name="g-content-type-get-icon"></a><h3>g_content_type_get_icon ()</h3>
201 <pre class="programlisting"><a class="link" href="GIcon.html" title="GIcon"><span class="returnvalue">GIcon</span></a> * g_content_type_get_icon (<em class="parameter"><code>const <a href="./../glib/glib/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *type</code></em>);</pre>
203 Gets the icon for a content type.
205 <div class="variablelist"><table border="0">
206 <col align="left" valign="top">
209 <td><p><span class="term"><em class="parameter"><code>type</code></em> :</span></p></td>
210 <td>a content type string</td>
213 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
215 <a class="link" href="GIcon.html" title="GIcon"><span class="type">GIcon</span></a> corresponding to the content type. Free the returned
216 object with <a href="./../gobject/gobject/gobject-The-Base-Object-Type.html#g-object-unref"><code class="function">g_object_unref()</code></a>. <span class="annotation">[<acronym title="Free data after the code is done."><span class="acronym">transfer full</span></acronym>]</span>
223 <div class="refsect2">
224 <a name="g-content-type-can-be-executable"></a><h3>g_content_type_can_be_executable ()</h3>
225 <pre class="programlisting"><a href="./../glib/glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> g_content_type_can_be_executable (<em class="parameter"><code>const <a href="./../glib/glib/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *type</code></em>);</pre>
227 Checks if a content type can be executable. Note that for instance
228 things like text files can be executables (i.e. scripts and batch files).
230 <div class="variablelist"><table border="0">
231 <col align="left" valign="top">
234 <td><p><span class="term"><em class="parameter"><code>type</code></em> :</span></p></td>
235 <td>a content type string</td>
238 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
240 <a href="./../glib/glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if the file type corresponds to a type that
241 can be executable, <a href="./../glib/glib/glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> otherwise.</td>
247 <div class="refsect2">
248 <a name="g-content-type-from-mime-type"></a><h3>g_content_type_from_mime_type ()</h3>
249 <pre class="programlisting"><a href="./../glib/glib/glib-Basic-Types.html#gchar"><span class="returnvalue">gchar</span></a> * g_content_type_from_mime_type (<em class="parameter"><code>const <a href="./../glib/glib/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *mime_type</code></em>);</pre>
251 Tries to find a content type based on the mime type name.
253 <div class="variablelist"><table border="0">
254 <col align="left" valign="top">
257 <td><p><span class="term"><em class="parameter"><code>mime_type</code></em> :</span></p></td>
258 <td>a mime type string</td>
261 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
262 <td>Newly allocated string with content type
263 or <a href="./../glib/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>. Free with <a href="./../glib/glib/glib-Memory-Allocation.html#g-free"><code class="function">g_free()</code></a>. <span class="annotation">[<acronym title="NULL is ok, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span>
268 <p class="since">Since 2.18</p>
271 <div class="refsect2">
272 <a name="g-content-type-guess"></a><h3>g_content_type_guess ()</h3>
273 <pre class="programlisting"><a href="./../glib/glib/glib-Basic-Types.html#gchar"><span class="returnvalue">gchar</span></a> * g_content_type_guess (<em class="parameter"><code>const <a href="./../glib/glib/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *filename</code></em>,
274 <em class="parameter"><code>const <a href="./../glib/glib/glib-Basic-Types.html#guchar"><span class="type">guchar</span></a> *data</code></em>,
275 <em class="parameter"><code><a href="./../glib/glib/glib-Basic-Types.html#gsize"><span class="type">gsize</span></a> data_size</code></em>,
276 <em class="parameter"><code><a href="./../glib/glib/glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a> *result_uncertain</code></em>);</pre>
278 Guesses the content type based on example data. If the function is
279 uncertain, <em class="parameter"><code>result_uncertain</code></em> will be set to <a href="./../glib/glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a>. Either <em class="parameter"><code>filename</code></em>
280 or <em class="parameter"><code>data</code></em> may be <a href="./../glib/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>, in which case the guess will be based solely
281 on the other argument.
283 <div class="variablelist"><table border="0">
284 <col align="left" valign="top">
287 <td><p><span class="term"><em class="parameter"><code>filename</code></em> :</span></p></td>
288 <td>a string, or <a href="./../glib/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>. <span class="annotation">[<acronym title="NULL is ok, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span>
292 <td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
293 <td>a stream of data, or <a href="./../glib/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>. <span class="annotation">[<acronym title="NULL is ok, both for passing and for returning."><span class="acronym">allow-none</span></acronym>][<acronym title="Parameter points to an array of items."><span class="acronym">array</span></acronym> length=data_size]</span>
297 <td><p><span class="term"><em class="parameter"><code>data_size</code></em> :</span></p></td>
298 <td>the size of <em class="parameter"><code>data</code></em>
302 <td><p><span class="term"><em class="parameter"><code>result_uncertain</code></em> :</span></p></td>
303 <td>return location for the certainty
304 of the result, or <a href="./../glib/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>. <span class="annotation">[<acronym title="NULL is ok, both for passing and for returning."><span class="acronym">allow-none</span></acronym>][<acronym title="Parameter for returning results. Default is transfer full."><span class="acronym">out</span></acronym>]</span>
308 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
309 <td>a string indicating a guessed content type for the
310 given data. Free with <a href="./../glib/glib/glib-Memory-Allocation.html#g-free"><code class="function">g_free()</code></a>
317 <div class="refsect2">
318 <a name="g-content-type-guess-for-tree"></a><h3>g_content_type_guess_for_tree ()</h3>
319 <pre class="programlisting"><a href="./../glib/glib/glib-Basic-Types.html#gchar"><span class="returnvalue">gchar</span></a> ** g_content_type_guess_for_tree (<em class="parameter"><code><a class="link" href="GFile.html" title="GFile"><span class="type">GFile</span></a> *root</code></em>);</pre>
321 Tries to guess the type of the tree with root <em class="parameter"><code>root</code></em>, by
322 looking at the files it contains. The result is an array
323 of content types, with the best guess coming first.
326 The types returned all have the form x-content/foo, e.g.
327 x-content/audio-cdda (for audio CDs) or x-content/image-dcf
328 (for a camera memory card). See the <a class="ulink" href="http://www.freedesktop.org/wiki/Specifications/shared-mime-info-spec" target="_top">shared-mime-info</a>
329 specification for more on x-content types.
332 This function is useful in the implementation of
333 <a class="link" href="GMount.html#g-mount-guess-content-type" title="g_mount_guess_content_type ()"><code class="function">g_mount_guess_content_type()</code></a>.
335 <div class="variablelist"><table border="0">
336 <col align="left" valign="top">
339 <td><p><span class="term"><em class="parameter"><code>root</code></em> :</span></p></td>
340 <td>the root of the tree to guess a type for</td>
343 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
344 <td>an <a href="./../glib/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>-terminated
345 array of zero or more content types. Free with <a href="./../glib/glib/glib-String-Utility-Functions.html#g-strfreev"><code class="function">g_strfreev()</code></a>. <span class="annotation">[<acronym title="Free data after the code is done."><span class="acronym">transfer full</span></acronym>][<acronym title="Parameter points to an array of items."><span class="acronym">array</span></acronym> zero-terminated=1]</span>
350 <p class="since">Since 2.18</p>
353 <div class="refsect2">
354 <a name="g-content-types-get-registered"></a><h3>g_content_types_get_registered ()</h3>
355 <pre class="programlisting"><a href="./../glib/glib/glib-Doubly-Linked-Lists.html#GList"><span class="returnvalue">GList</span></a> * g_content_types_get_registered (<em class="parameter"><code><span class="type">void</span></code></em>);</pre>
357 Gets a list of strings containing all the registered content types
358 known to the system. The list and its data should be freed using
360 <pre class="programlisting">
361 g_list_free_full (list, g_free);
365 <div class="variablelist"><table border="0">
366 <col align="left" valign="top">
368 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
370 <a href="./../glib/glib/glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a> of the registered content types. <span class="annotation">[<acronym title="Generics and defining elements of containers and arrays."><span class="acronym">element-type</span></acronym> utf8][<acronym title="Free data after the code is done."><span class="acronym">transfer full</span></acronym>]</span>
379 Generated by GTK-Doc V1.18</div>