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>MIME typing</title>
6
<meta name="generator" content="DocBook XSL Stylesheets V1.74.3">
7
<link rel="home" href="index.html" title="GnomeVFS - Filesystem Abstraction library">
8
<link rel="up" href="mime-registry.html" title="MIME Registry">
9
<link rel="prev" href="mime-registry.html" title="MIME Registry">
10
<link rel="next" href="gnome-vfs-2.0-gnome-vfs-mime-utils.html" title="gnome-vfs-mime-utils">
11
<meta name="generator" content="GTK-Doc V1.12 (XML mode)">
12
<link rel="stylesheet" href="style.css" type="text/css">
13
<link rel="chapter" href="about.html" title="Introduction to GnomeVFS">
14
<link rel="chapter" href="data-types.html" title="Basic Data Types">
15
<link rel="chapter" href="gnome-vfs-basic-file-ops.html" title="File Operations">
16
<link rel="chapter" href="gnome-vfs-directory-ops.html" title="Directory-Specific Operations">
17
<link rel="chapter" href="gnome-vfs-file-and-dirs-ops.html" title="Advanced File/Directory Operations">
18
<link rel="chapter" href="gnome-vfs-file-async-ops.html" title="Asynchronous Operations">
19
<link rel="chapter" href="volumes.html" title="Volumes and Drives Handling">
20
<link rel="chapter" href="networking.html" title="Networking">
21
<link rel="chapter" href="mime-registry.html" title="MIME Registry">
22
<link rel="chapter" href="modules.html" title="Filesystem Modules">
24
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
25
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
27
<td><a accesskey="p" href="mime-registry.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
28
<td><a accesskey="u" href="mime-registry.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
29
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
30
<th width="100%" align="center">GnomeVFS - Filesystem Abstraction library</th>
31
<td><a accesskey="n" href="gnome-vfs-2.0-gnome-vfs-mime-utils.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
33
<tr><td colspan="5" class="shortcuts">
34
<a href="#gnome-vfs-2.0-gnome-vfs-mime.synopsis" class="shortcut">Top</a>
36
<a href="#gnome-vfs-2.0-gnome-vfs-mime.description" class="shortcut">Description</a>
39
<div class="refentry" lang="en">
40
<a name="gnome-vfs-2.0-gnome-vfs-mime"></a><div class="titlepage"></div>
41
<div class="refnamediv"><table width="100%"><tr>
43
<h2><span class="refentrytitle"><a name="gnome-vfs-2.0-gnome-vfs-mime.top_of_page"></a>MIME typing</span></h2>
44
<p>MIME typing — functions to get a mime-type for a file using its name or its content</p>
46
<td valign="top" align="right"></td>
48
<div class="refsynopsisdiv">
49
<a name="gnome-vfs-2.0-gnome-vfs-mime.synopsis"></a><h2>Synopsis</h2>
50
<pre class="synopsis">
51
const char * <a class="link" href="gnome-vfs-2.0-gnome-vfs-mime.html#gnome-vfs-mime-type-from-name" title="gnome_vfs_mime_type_from_name ()">gnome_vfs_mime_type_from_name</a> (const char *filename);
52
const char * <a class="link" href="gnome-vfs-2.0-gnome-vfs-mime.html#gnome-vfs-mime-type-from-name-or-default" title="gnome_vfs_mime_type_from_name_or_default ()">gnome_vfs_mime_type_from_name_or_default</a>
53
(const char *filename,
54
const char *defaultv);
55
const char * <a class="link" href="gnome-vfs-2.0-gnome-vfs-mime.html#gnome-vfs-get-mime-type-common" title="gnome_vfs_get_mime_type_common ()">gnome_vfs_get_mime_type_common</a> (<a class="link" href="gnome-vfs-2.0-gnome-vfs-uri.html#GnomeVFSURI" title="GnomeVFSURI">GnomeVFSURI</a> *uri);
56
const char * <a class="link" href="gnome-vfs-2.0-gnome-vfs-mime.html#gnome-vfs-get-mime-type-from-uri" title="gnome_vfs_get_mime_type_from_uri ()">gnome_vfs_get_mime_type_from_uri</a> (<a class="link" href="gnome-vfs-2.0-gnome-vfs-uri.html#GnomeVFSURI" title="GnomeVFSURI">GnomeVFSURI</a> *uri);
57
const char * <a class="link" href="gnome-vfs-2.0-gnome-vfs-mime.html#gnome-vfs-get-mime-type-from-file-data" title="gnome_vfs_get_mime_type_from_file_data ()">gnome_vfs_get_mime_type_from_file_data</a>
58
(<a class="link" href="gnome-vfs-2.0-gnome-vfs-uri.html#GnomeVFSURI" title="GnomeVFSURI">GnomeVFSURI</a> *uri);
59
const char * <a class="link" href="gnome-vfs-2.0-gnome-vfs-mime.html#gnome-vfs-get-file-mime-type-fast" title="gnome_vfs_get_file_mime_type_fast ()">gnome_vfs_get_file_mime_type_fast</a> (const char *path,
60
const struct stat *optional_stat_info);
61
const char * <a class="link" href="gnome-vfs-2.0-gnome-vfs-mime.html#gnome-vfs-get-file-mime-type" title="gnome_vfs_get_file_mime_type ()">gnome_vfs_get_file_mime_type</a> (const char *path,
62
const struct stat *optional_stat_info,
63
gboolean suffix_only);
64
gboolean <a class="link" href="gnome-vfs-2.0-gnome-vfs-mime.html#gnome-vfs-mime-type-is-supertype" title="gnome_vfs_mime_type_is_supertype ()">gnome_vfs_mime_type_is_supertype</a> (const char *mime_type);
65
char * <a class="link" href="gnome-vfs-2.0-gnome-vfs-mime.html#gnome-vfs-get-supertype-from-mime-type" title="gnome_vfs_get_supertype_from_mime_type ()">gnome_vfs_get_supertype_from_mime_type</a>
66
(const char *mime_type);
67
void <a class="link" href="gnome-vfs-2.0-gnome-vfs-mime.html#gnome-vfs-mime-info-cache-reload" title="gnome_vfs_mime_info_cache_reload ()">gnome_vfs_mime_info_cache_reload</a> (const char *dir);
68
void <a class="link" href="gnome-vfs-2.0-gnome-vfs-mime.html#gnome-vfs-mime-reload" title="gnome_vfs_mime_reload ()">gnome_vfs_mime_reload</a> (void);
69
void <a class="link" href="gnome-vfs-2.0-gnome-vfs-mime.html#gnome-vfs-mime-shutdown" title="gnome_vfs_mime_shutdown ()">gnome_vfs_mime_shutdown</a> (void);
72
<div class="refsect1" lang="en">
73
<a name="gnome-vfs-2.0-gnome-vfs-mime.description"></a><h2>Description</h2>
77
<div class="refsect1" lang="en">
78
<a name="gnome-vfs-2.0-gnome-vfs-mime.details"></a><h2>Details</h2>
79
<div class="refsect2" lang="en">
80
<a name="gnome-vfs-mime-type-from-name"></a><h3>gnome_vfs_mime_type_from_name ()</h3>
81
<pre class="programlisting">const char * gnome_vfs_mime_type_from_name (const char *filename);</pre>
82
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
83
<h3 class="title">Warning</h3>
84
<p><code class="literal">gnome_vfs_mime_type_from_name</code> is deprecated and should not be used in newly-written code. This function is deprecated, use
85
<a class="link" href="gnome-vfs-2.0-gnome-vfs-mime-utils.html#gnome-vfs-get-mime-type-for-name" title="gnome_vfs_get_mime_type_for_name ()"><code class="function">gnome_vfs_get_mime_type_for_name()</code></a> instead.</p>
88
Determine the mime type for <em class="parameter"><code>filename</code></em>.</p>
91
<div class="variablelist"><table border="0">
92
<col align="left" valign="top">
95
<td><p><span class="term"><em class="parameter"><code>filename</code></em> :</span></p></td>
96
<td> a filename (the file does not necessarily exist).
100
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
101
<td> the mime-type for this filename. Will return
102
<a class="link" href="gnome-vfs-2.0-gnome-vfs-mime-utils.html#GNOME-VFS-MIME-TYPE-UNKNOWN:CAPS" title="GNOME_VFS_MIME_TYPE_UNKNOWN"><code class="literal">GNOME_VFS_MIME_TYPE_UNKNOWN</code></a> if mime-type could not be found.
109
<div class="refsect2" lang="en">
110
<a name="gnome-vfs-mime-type-from-name-or-default"></a><h3>gnome_vfs_mime_type_from_name_or_default ()</h3>
111
<pre class="programlisting">const char * gnome_vfs_mime_type_from_name_or_default
112
(const char *filename,
113
const char *defaultv);</pre>
115
This routine tries to determine the mime-type of the filename
116
only by looking at the filename from the GNOME database of mime-types.</p>
119
<div class="variablelist"><table border="0">
120
<col align="left" valign="top">
123
<td><p><span class="term"><em class="parameter"><code>filename</code></em> :</span></p></td>
124
<td> a filename (the file does not necessarily exist).
128
<td><p><span class="term"><em class="parameter"><code>defaultv</code></em> :</span></p></td>
129
<td> a default value to be returned if no match is found.
133
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
134
<td> the mime-type of the <em class="parameter"><code>filename</code></em>. If no value could be
135
determined, it will return <em class="parameter"><code>defaultv</code></em>.
142
<div class="refsect2" lang="en">
143
<a name="gnome-vfs-get-mime-type-common"></a><h3>gnome_vfs_get_mime_type_common ()</h3>
144
<pre class="programlisting">const char * gnome_vfs_get_mime_type_common (<a class="link" href="gnome-vfs-2.0-gnome-vfs-uri.html#GnomeVFSURI" title="GnomeVFSURI">GnomeVFSURI</a> *uri);</pre>
146
Tries to guess the mime type of the file represented by <em class="parameter"><code>uri</code></em>.
147
Favors using the file data to the <em class="parameter"><code>uri</code></em> extension.
148
Handles <em class="parameter"><code>uri</code></em> of a non-existent file by falling back
149
on returning a type based on the extension. If cant find the mime-type based on the
150
extension also then returns 'application/octet-stream'.
153
FIXME: This function will not necessarily return the same mime type as doing a
154
get file info on the text uri.</p>
157
<div class="variablelist"><table border="0">
158
<col align="left" valign="top">
161
<td><p><span class="term"><em class="parameter"><code>uri</code></em> :</span></p></td>
162
<td> a real file or a non-existent uri.
166
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
167
<td> the mime-type for <em class="parameter"><code>uri</code></em>.
174
<div class="refsect2" lang="en">
175
<a name="gnome-vfs-get-mime-type-from-uri"></a><h3>gnome_vfs_get_mime_type_from_uri ()</h3>
176
<pre class="programlisting">const char * gnome_vfs_get_mime_type_from_uri (<a class="link" href="gnome-vfs-2.0-gnome-vfs-uri.html#GnomeVFSURI" title="GnomeVFSURI">GnomeVFSURI</a> *uri);</pre>
178
Tries to guess the mime type of the file <em class="parameter"><code>uri</code></em> by
179
checking the file name extension. Works on non-existent
183
<div class="variablelist"><table border="0">
184
<col align="left" valign="top">
187
<td><p><span class="term"><em class="parameter"><code>uri</code></em> :</span></p></td>
192
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
193
<td> the mime-type for file at <em class="parameter"><code>uri</code></em>.
200
<div class="refsect2" lang="en">
201
<a name="gnome-vfs-get-mime-type-from-file-data"></a><h3>gnome_vfs_get_mime_type_from_file_data ()</h3>
202
<pre class="programlisting">const char * gnome_vfs_get_mime_type_from_file_data
203
(<a class="link" href="gnome-vfs-2.0-gnome-vfs-uri.html#GnomeVFSURI" title="GnomeVFSURI">GnomeVFSURI</a> *uri);</pre>
204
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
205
<h3 class="title">Warning</h3>
206
<p><code class="literal">gnome_vfs_get_mime_type_from_file_data</code> is deprecated and should not be used in newly-written code. </p>
209
Tries to guess the mime type of the file <em class="parameter"><code>uri</code></em> by
210
checking the file data using the magic patterns. Does not handle text files properly.</p>
213
<div class="variablelist"><table border="0">
214
<col align="left" valign="top">
217
<td><p><span class="term"><em class="parameter"><code>uri</code></em> :</span></p></td>
222
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
223
<td> the mime-type for this filename.
230
<div class="refsect2" lang="en">
231
<a name="gnome-vfs-get-file-mime-type-fast"></a><h3>gnome_vfs_get_file_mime_type_fast ()</h3>
232
<pre class="programlisting">const char * gnome_vfs_get_file_mime_type_fast (const char *path,
233
const struct stat *optional_stat_info);</pre>
235
Tries to guess the mime type of the file represented by <em class="parameter"><code>path</code></em>.
236
It uses extention/name detection first, and if that fails
237
it falls back to mime-magic based lookup. This is faster
238
than always doing mime-magic but doesn't always produce
239
the right answer, so for important decisions
240
you should use <a class="link" href="gnome-vfs-2.0-gnome-vfs-mime.html#gnome-vfs-get-file-mime-type" title="gnome_vfs_get_file_mime_type ()"><code class="function">gnome_vfs_get_file_mime_type()</code></a>.</p>
243
<div class="variablelist"><table border="0">
244
<col align="left" valign="top">
247
<td><p><span class="term"><em class="parameter"><code>path</code></em> :</span></p></td>
248
<td> path of the file whose mime type is to be found out.
252
<td><p><span class="term"><em class="parameter"><code>optional_stat_info</code></em> :</span></p></td>
253
<td> optional stat buffer.
257
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
258
<td> the mime-type for file at <em class="parameter"><code>path</code></em>.
265
<div class="refsect2" lang="en">
266
<a name="gnome-vfs-get-file-mime-type"></a><h3>gnome_vfs_get_file_mime_type ()</h3>
267
<pre class="programlisting">const char * gnome_vfs_get_file_mime_type (const char *path,
268
const struct stat *optional_stat_info,
269
gboolean suffix_only);</pre>
271
Tries to guess the mime type of the file represented by <em class="parameter"><code>path</code></em>.
272
If <em class="parameter"><code>suffix_only</code></em> is false, uses the mime-magic based lookup first.
273
Handles <em class="parameter"><code>path</code></em> of a non-existent file by falling back
274
on returning a type based on the extension.
277
If you need a faster, less accurate version, use
278
<a class="link" href="gnome-vfs-2.0-gnome-vfs-mime.html#gnome-vfs-get-file-mime-type-fast" title="gnome_vfs_get_file_mime_type_fast ()"><code class="function">gnome_vfs_get_file_mime_type_fast()</code></a>.</p>
281
<div class="variablelist"><table border="0">
282
<col align="left" valign="top">
285
<td><p><span class="term"><em class="parameter"><code>path</code></em> :</span></p></td>
286
<td> path of a file whose mime type is to be found out.
290
<td><p><span class="term"><em class="parameter"><code>optional_stat_info</code></em> :</span></p></td>
291
<td> optional stat buffer.
295
<td><p><span class="term"><em class="parameter"><code>suffix_only</code></em> :</span></p></td>
296
<td> whether or not to do a magic-based lookup.
300
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
301
<td> the mime-type for file at <em class="parameter"><code>path</code></em>.
308
<div class="refsect2" lang="en">
309
<a name="gnome-vfs-mime-type-is-supertype"></a><h3>gnome_vfs_mime_type_is_supertype ()</h3>
310
<pre class="programlisting">gboolean gnome_vfs_mime_type_is_supertype (const char *mime_type);</pre>
313
<div class="variablelist"><table border="0">
314
<col align="left" valign="top">
317
<td><p><span class="term"><em class="parameter"><code>mime_type</code></em> :</span></p></td>
318
<td> a const char * identifying a mime type.
322
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
323
<td> Whether <em class="parameter"><code>mime_type</code></em> is of the form "foo<code class="literal">/</code>*".
330
<div class="refsect2" lang="en">
331
<a name="gnome-vfs-get-supertype-from-mime-type"></a><h3>gnome_vfs_get_supertype_from_mime_type ()</h3>
332
<pre class="programlisting">char * gnome_vfs_get_supertype_from_mime_type
333
(const char *mime_type);</pre>
336
<div class="variablelist"><table border="0">
337
<col align="left" valign="top">
340
<td><p><span class="term"><em class="parameter"><code>mime_type</code></em> :</span></p></td>
341
<td> mime type to get the supertype for.
345
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
346
<td> The supertype for <em class="parameter"><code>mime_type</code></em>, allocating new memory.
348
The supertype of an application is computed by removing its
349
suffix, and replacing it with "*". Thus, "foo/bar" will be
350
converted to "foo<code class="literal">/</code>*".
352
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
353
<h3 class="title">Note</h3>
354
If this function is called on a supertype, it will return a copy of the supertype.
362
<div class="refsect2" lang="en">
363
<a name="gnome-vfs-mime-info-cache-reload"></a><h3>gnome_vfs_mime_info_cache_reload ()</h3>
364
<pre class="programlisting">void gnome_vfs_mime_info_cache_reload (const char *dir);</pre>
366
Reload the mime information for the <em class="parameter"><code>dir</code></em>.</p>
369
<div class="variablelist"><table border="0">
370
<col align="left" valign="top">
372
<td><p><span class="term"><em class="parameter"><code>dir</code></em> :</span></p></td>
373
<td> directory path which needs reloading.
379
<div class="refsect2" lang="en">
380
<a name="gnome-vfs-mime-reload"></a><h3>gnome_vfs_mime_reload ()</h3>
381
<pre class="programlisting">void gnome_vfs_mime_reload (void);</pre>
383
Reload the MIME database.</p>
388
<div class="refsect2" lang="en">
389
<a name="gnome-vfs-mime-shutdown"></a><h3>gnome_vfs_mime_shutdown ()</h3>
390
<pre class="programlisting">void gnome_vfs_mime_shutdown (void);</pre>
391
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
392
<h3 class="title">Warning</h3>
393
<p><code class="literal">gnome_vfs_mime_shutdown</code> is deprecated and should not be used in newly-written code. This function doesn't have to be called as the
394
operating system automatically cleans up resources when exiting.
397
Unload the MIME database from memory.</p>
406
Generated by GTK-Doc V1.12</div>