<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <meta http-equiv="X-UA-Compatible" content="IE=9"/> <title>edelib: MimeType Class Reference</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="doxygen.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="top"><!-- do not remove this div! --> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td style="padding-left: 0.5em;"> <div id="projectname">edelib  <span id="projectnumber">2.0.0</span> </div> </td> </tr> </tbody> </table> </div> <!-- Generated by Doxygen 1.7.6.1 --> <div id="navrow1" class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="modules.html"><span>Modules</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li class="current"><a href="annotated.html"><span>Classes</span></a></li> <li><a href="files.html"><span>Files</span></a></li> </ul> </div> <div id="navrow2" class="tabs2"> <ul class="tablist"> <li><a href="annotated.html"><span>Class List</span></a></li> <li><a href="hierarchy.html"><span>Class Hierarchy</span></a></li> <li><a href="functions.html"><span>Class Members</span></a></li> </ul> </div> <div id="nav-path" class="navpath"> <ul> <li class="navelem"><a class="el" href="namespaceedelib.html">edelib</a> </li> <li class="navelem"><a class="el" href="classedelib_1_1MimeType.html">MimeType</a> </li> </ul> </div> </div> <div class="header"> <div class="summary"> <a href="#pub-methods">Public Member Functions</a> </div> <div class="headertitle"> <div class="title">MimeType Class Reference</div> </div> </div><!--header--> <div class="contents"> <!-- doxytag: class="edelib::MimeType" --> <p>Mime handling class. <a href="classedelib_1_1MimeType.html#details">More...</a></p> <p><code>#include <<a class="el" href="MimeType_8h_source.html">edelib/MimeType.h</a>></code></p> <p><a href="classedelib_1_1MimeType-members.html">List of all members.</a></p> <table class="memberdecls"> <tr><td colspan="2"><h2><a name="pub-methods"></a> Public Member Functions</h2></td></tr> <tr><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classedelib_1_1MimeType.html#accf8cc9b7d7e674571ceef21060ead2b">MimeType</a> ()</td></tr> <tr><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classedelib_1_1MimeType.html#a7644704b5c1f7180aa279873da87a277">~MimeType</a> ()</td></tr> <tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classedelib_1_1MimeType.html#ae18b4b64d71a4654737c5917b16ffe58">set</a> (const char *filename)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">const <a class="el" href="classedelib_1_1String.html">String</a> & </td><td class="memItemRight" valign="bottom"><a class="el" href="classedelib_1_1MimeType.html#a7a0100bffef0dcd42cf9c7d1910e4f84">type</a> (void) const </td></tr> <tr><td class="memItemLeft" align="right" valign="top">const <a class="el" href="classedelib_1_1String.html">String</a> & </td><td class="memItemRight" valign="bottom"><a class="el" href="classedelib_1_1MimeType.html#a9a51f4dd3b084635447276d285b65220">comment</a> (void)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classedelib_1_1MimeType.html#a4d147a740fee14d00ac513f639a01ed4">subclass_of</a> (const char *mime)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">const <a class="el" href="classedelib_1_1String.html">String</a> & </td><td class="memItemRight" valign="bottom"><a class="el" href="classedelib_1_1MimeType.html#a6e581af8f7875468a529f2ec550c8485">icon_name</a> (void)</td></tr> </table> <hr/><a name="details" id="details"></a><h2>Detailed Description</h2> <div class="textblock"><p>Mime handling class. </p> <p><a class="el" href="classedelib_1_1MimeType.html" title="Mime handling class.">MimeType</a> will handle file types according to specification at <a href="http://www.freedesktop.org">http://www.freedesktop.org</a>. This class depends on <em>shared-mime-info</em> package, usually shipped with todays distributions.</p> <p>It will try to recognize given file looking into $XDG_DATA_DIRS/mime/magic database, consulting $XDG_DATA_DIRS/mime/aliases for potential type * aliasing.</p> <p>Returned values from <a class="el" href="classedelib_1_1MimeType.html#a7a0100bffef0dcd42cf9c7d1910e4f84">type()</a> will be in the form <em>context/file-type</em>, so, for example, for given file foo.tar.gz will be <em>application/x-compressed-tar</em> or for baz.jpg will be <em>image/jpeg</em>.</p> <p>If file could not be recognized, returned string will be <em>application/octet-stream</em>.</p> <p><a class="el" href="classedelib_1_1MimeType.html#a9a51f4dd3b084635447276d285b65220">comment()</a> will return full description for recognized file, looking inside $XDG_DATA_DIRS/mime/context/file-type.xml file. This description can be plain english (default) or localized (not implemented yet).</p> <dl class="todo"><dt><b><a class="el" href="todo.html#_todo000022">Todo:</a></b></dt><dd><p class="startdd">add locale during read of comments </p> <p class="enddd">Last change in xdgmime.c moved stat-ed code to be executed first so ambiguous directory names (like ".kde" or ".emacs.d" or ".e") doesn't be recognized as files or unknown types; can stat's be delayed? </p> </dd></dl> </div><hr/><h2>Constructor & Destructor Documentation</h2> <a class="anchor" id="accf8cc9b7d7e674571ceef21060ead2b"></a><!-- doxytag: member="edelib::MimeType::MimeType" ref="accf8cc9b7d7e674571ceef21060ead2b" args="()" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname"><a class="el" href="classedelib_1_1MimeType.html">MimeType</a> </td> <td>(</td> <td class="paramname"></td><td>)</td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Empty constructor </p> </div> </div> <a class="anchor" id="a7644704b5c1f7180aa279873da87a277"></a><!-- doxytag: member="edelib::MimeType::~MimeType" ref="a7644704b5c1f7180aa279873da87a277" args="()" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">~<a class="el" href="classedelib_1_1MimeType.html">MimeType</a> </td> <td>(</td> <td class="paramname"></td><td>)</td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Cleans internal data </p> </div> </div> <hr/><h2>Member Function Documentation</h2> <a class="anchor" id="a9a51f4dd3b084635447276d285b65220"></a><!-- doxytag: member="edelib::MimeType::comment" ref="a9a51f4dd3b084635447276d285b65220" args="(void)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">const <a class="el" href="classedelib_1_1String.html">String</a>& <a class="el" href="classedelib_1_1MimeType.html#a9a51f4dd3b084635447276d285b65220">comment</a> </td> <td>(</td> <td class="paramtype">void </td> <td class="paramname"></td><td>)</td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Lookup for description described at the beggining of this document. If file with description does not exists, it will return empty string. </p> </div> </div> <a class="anchor" id="a6e581af8f7875468a529f2ec550c8485"></a><!-- doxytag: member="edelib::MimeType::icon_name" ref="a6e581af8f7875468a529f2ec550c8485" args="(void)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">const <a class="el" href="classedelib_1_1String.html">String</a>& <a class="el" href="classedelib_1_1MimeType.html#a6e581af8f7875468a529f2ec550c8485">icon_name</a> </td> <td>(</td> <td class="paramtype">void </td> <td class="paramname"></td><td>)</td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Try to guess the name of possible icon (the name can be used for <a class="el" href="classedelib_1_1IconLoader.html" title="Loads icons with IconTheme.">edelib::IconLoader</a> and <a class="el" href="classedelib_1_1IconTheme.html" title="Finds named icon according to the given theme.">edelib::IconTheme</a>). Generally the icon used for a mimetype is created based on the mime-type by mapping "/" characters to "-", but it can overriden by writing entry in <em>icons</em> file. This file will be searched in <a class="el" href="namespaceedelib.html#a1df337e80676a135acf16c87508023e0">user_data_dir()</a> and <a class="el" href="namespaceedelib.html#a28c3fcbf73ec7216ec3fa9ff370432a4">system_data_dirs()</a> directories.</p> <p>icons file looks like: </p> <div class="fragment"><pre class="fragment"><span class="preprocessor"> # this is comment</span> <span class="preprocessor"></span> text/plain:icon-name application/octet-stream:another-icon <span class="preprocessor"> # this is bad and will not be read</span> <span class="preprocessor"> application/octet-stream : icon</span> </pre></div><dl class="note"><dt><b>Note:</b></dt><dd>This rule does not applies for <em>node/xxx</em> (where xxx is folder,socket,fifo, etc.). According to the icon naming specs, icon names should be file,socket,folder,...</dd> <dd> For folders icon name will be <em>folder</em> due compatibility with icon naming standard.</dd></dl> <p>If <a class="el" href="classedelib_1_1MimeType.html#ae18b4b64d71a4654737c5917b16ffe58">set()</a> failed, it will return empty string. </p> </div> </div> <a class="anchor" id="ae18b4b64d71a4654737c5917b16ffe58"></a><!-- doxytag: member="edelib::MimeType::set" ref="ae18b4b64d71a4654737c5917b16ffe58" args="(const char *filename)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">bool <a class="el" href="classedelib_1_1MimeType.html#ae18b4b64d71a4654737c5917b16ffe58">set</a> </td> <td>(</td> <td class="paramtype">const char * </td> <td class="paramname"><em>filename</em></td><td>)</td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Set path to the file for inspection. If file does not exists or is unreadable, it will return false.</p> <dl class="return"><dt><b>Returns:</b></dt><dd>true if manage to access file, otherwise false </dd></dl> <dl class="params"><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">filename</td><td>is full path to file </td></tr> </table> </dd> </dl> </div> </div> <a class="anchor" id="a4d147a740fee14d00ac513f639a01ed4"></a><!-- doxytag: member="edelib::MimeType::subclass_of" ref="a4d147a740fee14d00ac513f639a01ed4" args="(const char *mime)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">bool <a class="el" href="classedelib_1_1MimeType.html#a4d147a740fee14d00ac513f639a01ed4">subclass_of</a> </td> <td>(</td> <td class="paramtype">const char * </td> <td class="paramname"><em>mime</em></td><td>)</td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Returns true if current mime type is subclass of given parameter name. </p> </div> </div> <a class="anchor" id="a7a0100bffef0dcd42cf9c7d1910e4f84"></a><!-- doxytag: member="edelib::MimeType::type" ref="a7a0100bffef0dcd42cf9c7d1910e4f84" args="(void) const " --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">const <a class="el" href="classedelib_1_1String.html">String</a>& <a class="el" href="classedelib_1_1MimeType.html#a7a0100bffef0dcd42cf9c7d1910e4f84">type</a> </td> <td>(</td> <td class="paramtype">void </td> <td class="paramname"></td><td>)</td> <td> const</td> </tr> </table> </div> <div class="memdoc"> <p>Return context/file-type form for file, given with <a class="el" href="classedelib_1_1MimeType.html#ae18b4b64d71a4654737c5917b16ffe58">set()</a>. If <a class="el" href="classedelib_1_1MimeType.html#ae18b4b64d71a4654737c5917b16ffe58">set()</a> failed, it will return empty string. </p> </div> </div> <hr/>The documentation for this class was generated from the following file:<ul> <li>edelib/<a class="el" href="MimeType_8h_source.html">MimeType.h</a></li> </ul> </div><!-- contents --> <hr class="footer"/><address class="footer"><small> Generated on Tue Jun 5 2012 17:49:03 for edelib by  <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/> </a> 1.7.6.1 </small></address> </body> </html>