haiku-website/static/legacy-docs/bebook/BMimeType_Overview.html

75 lines
7.4 KiB
HTML
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>The Be Book - System Overview - The Storage Kit</title><link rel="stylesheet" href="be_book.css" type="text/css" media="all" /><link rel="shortcut icon" type="image/vnd.microsoft.icon" href="./images/favicon.ico" /><!--[if IE]>
<link rel="stylesheet" type="text/css" href="be_book_ie.css" />
<![endif]--><meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /><meta name="keywords" content="Access, BeOS, BeBook, API" /><link rel="start" href="index.html" title="The Be Book" /><link rel="up" href="TheStorageKit_Overview.html" title="The Storage Kit" /><link rel="prev" href="BFilePanel_Overview.html" title="BFilePanel" /><link rel="next" href="BNode_Overview.html" title="BNode" /></head><body><div id="header"><div id="headerT"><div id="headerTL"><a accesskey="p" href="BFilePanel_Overview.html" title="BFilePanel"><img src="./images/navigation/prev.png" alt="Prev" /></a> <a accesskey="u" href="TheStorageKit_Overview.html" title="The Storage Kit"><img src="./images/navigation/up.png" alt="Up" /></a> <a accesskey="n" href="BNode_Overview.html" title="BNode"><img src="./images/navigation/next.png" alt="Next" /></a></div><div id="headerTR"><div id="navigpeople"><a href="http://www.haiku-os.org"><img src="./images/People_24.png" alt="haiku-os.org" title="Visit The Haiku Website" /></a></div><div class="navighome" title="Home"><a accesskey="h" href="index.html"><img src="./images/navigation/home.png" alt="Home" /></a></div><div class="navigboxed" id="navigindex"><a accesskey="i" href="ClassIndex.html" title="Index">I</a></div><div class="navigboxed" id="naviglang" title="English">en</div></div><div id="headerTC">The Be Book - System Overview - The Storage Kit</div></div><div id="headerB">Prev: <a href="BFilePanel_Overview.html">BFilePanel</a>  Up: <a href="TheStorageKit_Overview.html">The Storage Kit</a>  Next: <a href="BNode_Overview.html">BNode</a></div><hr /></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h2 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BMimeType_Overview"></a>BMimeType</h2></div></div></div><a id="id608284" class="indexterm"></a><p>
The <code class="classname">BMimeType</code> class provides three services:
</p><ul class="itemizedlist"><li><p>
It can parse a MIME string. It can tell you whether the string is
valid, what it's supertype component is, and whether it has a subtype
component. (The MIME string format is described in "Valid MIME Strings."
</p></li><li><p>
It gives you access to the File Type database. Given a MIME type, it
can look in the database and retrieve that type's icon(s), "preferred
handler" application, the filename extensions that correspond to it,
and so on.
</p></li><li><p>
It can regard a MIME string as an application signature, and so get
and set the executable file, the file types, and the document icons
that correspond to that signature.
</p></li></ul><p>
All three services operate on MIME strings. In other words, they answer
questions such as "Does this string have a supertype?", "Is this string
installed in the database?", and so on. You can get the MIME strings from
anywhere: from a file's file type attribute, from and application's
signature, from the header of an e-mail message, you can even make them
up.
</p><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><hr /><div xmlns:d="http://docbook.org/ns/docbook"><h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BMimeType_Valid_MIME_Strings"></a>Valid MIME Strings</h3></div></div></div><p>
A valid MIME string takes the form…
</p><pre class="screen">
supertype/[subtype]
</pre><p>
…where supertype is one of the seven "media" strings:
</p><ul class="itemizedlist"><li><p>
text
</p></li><li><p>
application
</p></li><li><p>
image
</p></li><li><p>
audio
</p></li><li><p>
video
</p></li><li><p>
multipart
</p></li><li><p>
message
</p></li></ul><p>
…and (the optional) subtype can be just about anything… Except it
can't include spaces or any of these forbidden characters:
</p><pre class="screen">
* / &lt; &gt; @ , ; : " ( ) [ ] ? =
</pre><p>
When you initialize a <code class="classname">BMimeType</code> object (through the constructor or
<a class="link" href="BMimeType.html#BMimeType_SetTo" title="SetTo(), Unset()"><code class="methodname">SetTo()</code></a>
function), you have to tell it what MIME string you want it to represent:
</p><ul class="itemizedlist"><li><p>
The string can be supertype-only, or it can be supertype/subtype.
</p></li><li><p>
Currently, the supertype is not restricted to the seven types listed
above, but you're probably making a mistake if you make up a new,
unrecognized supertype.
</p></li><li><p>
Neither the supertype nor the subtype can include any of the
forbidden characters.
</p></li><li><p>
The entire string must be no longer than <code class="constant">B_MIME_TYPE_LENGTH</code>
characters long. (That's about 240 characters. More than enough.)
</p></li></ul><p>
You can check the validity of a MIME string without constructing a
<code class="classname">BMimeType</code> object by calling the static
<a class="link" href="BMimeType.html#BMimeType_IsValid" title="IsValid(), IsSupertypeOnly()"><code class="methodname">IsValid()</code></a> function:
</p><pre class="programlisting example cpp"><code class="classname">BMimeType</code>::<code class="methodname">IsValid</code>("text/qwerty");</pre></div></div><div id="footer"><hr /><div id="footerT">Prev: <a href="BFilePanel_Overview.html">BFilePanel</a>  Up: <a href="TheStorageKit_Overview.html">The Storage Kit</a>  Next: <a href="BNode_Overview.html">BNode</a> </div><div id="footerB"><div id="footerBL"><a href="BFilePanel_Overview.html" title="BFilePanel"><img src="./images/navigation/prev.png" alt="Prev" /></a> <a href="TheStorageKit_Overview.html" title="The Storage Kit"><img src="./images/navigation/up.png" alt="Up" /></a> <a href="BNode_Overview.html" title="BNode"><img src="./images/navigation/next.png" alt="Next" /></a></div><div id="footerBR"><div><a href="http://www.haiku-os.org"><img src="./images/People_24.png" alt="haiku-os.org" title="Visit The Haiku Website" /></a></div><div class="navighome" title="Home"><a accesskey="h" href="index.html"><img src="./images/navigation/home.png" alt="Home" /></a></div></div><div id="footerBC"><a href="http://www.access-company.com/home.html" title="ACCESS Co."><img alt="Access Company" src="./images/access_logo.png" /></a></div></div></div><div id="licenseFooter"><div id="licenseFooterBL"><a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/3.0/" title="Creative Commons License"><img alt="Creative Commons License" style="border-width:0" src="https://licensebuttons.net/l/by-nc-nd/3.0/88x31.png" /></a></div><div id="licenseFooterBR"><a href="./LegalNotice.html">Legal Notice</a></div><div id="licenseFooterBC"><span id="licenseText">This work is licensed under a
<a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/3.0/">Creative
Commons Attribution-Non commercial-No Derivative Works 3.0 License</a>.</span></div></div></body></html>