1 <!DOCTYPE REFENTRY PUBLIC "-//Sun Microsystems//DTD DocBook V3.0-Based SolBook Subset V2.0//EN" [ 2 <!--ArborText, Inc., 1988-1999, v.4002--> 3 <!--ARC : LSARC 2001/201 GNOME 2.X on Solaris--> 4 <!ENTITY cmd "gnome-vfs-mime-magic"> 5 <!ENTITY % commonents SYSTEM "smancommon.ent"> 6 %commonents; 7 <!ENTITY % booktitles SYSTEM "booktitles.ent"> 8 %booktitles; 9 <!ENTITY suncopy "Copyright (c) 2003,2008 Sun Microsystems, Inc. All Rights Reserved."> 10 ]> 11 <?Pub UDT _bookmark _target> 12 <?Pub EntList brvbar bull cross dash diam diams frac12 frac13 frac14 hellip 13 laquo lArr loz mdash nabla ndash para pound rArr raquo sect yen bsol> 14 <?Pub Inc> 15 <refentry id="gnome-vfs-mime-magic-4"> 16 <!-- %Z%%M% %I% %E% SMI; --> 17 <refmeta><refentrytitle>gnome-vfs-mime-magic.4</refentrytitle><manvolnum>4</manvolnum> 18 <refmiscinfo class="date">14 May 2008</refmiscinfo> 19 <refmiscinfo class="sectdesc">&man4;</refmiscinfo> 20 <refmiscinfo class="software">&release;</refmiscinfo> 21 <refmiscinfo class="arch">generic</refmiscinfo> 22 <refmiscinfo class="copyright">&suncopy;</refmiscinfo> 23 </refmeta> 24 <indexterm><primary>gnome-vfs-mime-magic</primary></indexterm><indexterm> 25 <primary>gnome-mime-info</primary></indexterm><indexterm><primary>gnome-mime-keys 26 </primary></indexterm><indexterm><primary>GNOME VFS MIME detection</primary> 27 </indexterm><refnamediv id="gnome-vfs-mime-magic-4-name"><refname>gnome-vfs-mime-magic</refname> 28 <refname>gnome-vfs.mime</refname><refname>gnome-vfs.keys</refname><refpurpose> 29 GNOME VFS MIME detection</refpurpose></refnamediv> 30 <refsect1 id="gnome-vfs-mime-magic-4-desc"><title>&desc-tt;</title> 31 <para> 32 GnomeVFS is obsolete. Refer to the GNOME Desktop System Administration 33 Guide for information about how to register MIME type information with 34 the GNOME desktop. The GNOME Desktop System Administration Guide can 35 be viewed with 36 <citerefentry><refentrytitle>yelp</refentrytitle><manvolnum>1</manvolnum></citerefentry>. 37 </para> 38 <para>On any modern desktop system, each document type or file type must be 39 given a unique identification name and icon. In GNOME, this information is 40 used extensively by the file manager, <citerefentry><refentrytitle>nautilus 41 </refentrytitle><manvolnum>1</manvolnum></citerefentry>. The primary underlying 42 mechanism for providing such definitions is achieved via <command>&cmd;</command>. <command>&cmd;</command> 43 contains the default file content sniffers for identifying MIME types. The 44 concept of MIME magic is similar to that of Solaris <citerefentry><refentrytitle> 45 magic</refentrytitle><manvolnum>4</manvolnum></citerefentry>.</para> 46 </refsect1> 47 <refsect1 id="gnome-vfs-mime-magic-4-exde"><title>&exde-tt;</title> 48 <refsect2 id="gnome-vfs-mime-magic-4-exde-cmd"><title>&cmd;</title> 49 <para>Each line in the <filename>/etc/gnome/gnome-vfs-mime-magic</filename> 50 file describes a MIME type. The format of each line is as follows:<screen><computeroutput><replaceable> 51 offset_start</replaceable>[:<replaceable>offset_end</replaceable>] <replaceable> 52 pattern_type</replaceable> <replaceable>pattern</replaceable> [&<replaceable> 53 pattern_mask</replaceable>] <replaceable>mime-type</replaceable></computeroutput></screen></para> 54 <para>Each line contains the following fields:</para> 55 <variablelist><varlistentry><term><replaceable>offset_start</replaceable></term> 56 <listitem><para>Decimal number that, with <replaceable>offset_end</replaceable>, 57 specifies the bytes offset within the file.</para> 58 </listitem></varlistentry> 59 <varlistentry><term><replaceable>offset_end</replaceable></term><listitem> 60 <para>Decimal number that, with <replaceable>offset_start</replaceable>, specifies 61 the bytes offset within the file.</para> 62 </listitem></varlistentry> 63 <varlistentry><term><replaceable>pattern_type</replaceable></term><listitem> 64 <para>Can be one of the following types:</para> 65 <para><literal>byte | short | long | string | date | beshort | belong | bedate 66 | leshort | lelong | ledate</literal></para> 67 <para>where <literal>be</literal> stands for Big Endian and <literal>le</literal> 68 stands for Little Endian.</para> 69 </listitem></varlistentry> 70 <varlistentry><term><replaceable>pattern</replaceable></term><listitem><para> 71 An ASCII string with non-printable characters escaped as hex or octal escape 72 sequences, and spaces and other important whitespace escaped with a backslash 73 (<literal>\\</literal>).</para> 74 </listitem></varlistentry> 75 <varlistentry><term><replaceable>pattern_mask</replaceable></term><listitem> 76 <para>A string of hex digits. The mask must be the same specification as the 77 non-ambiguous patterns.</para> 78 </listitem></varlistentry> 79 <varlistentry><term><replaceable>mime-type</replaceable></term><listitem> 80 <para>A valid MIME type.</para> 81 </listitem></varlistentry> 82 </variablelist><para>The magic patterns are matched sequentially from the 83 first entry to the last entry of the list. Therefore, you should put the non-ambiguous 84 patterns at the start of the list. Any pattern that requires a deep seek into 85 the file should be placed at the end of the list to reduce performance overhead. 86 When designing new document formats, include an easily recognizable unique 87 magic pattern near the start of the file. A good pattern is is at least four 88 bytes long and contains one or two non-printable characters so that text files 89 are not misidentified.</para> 90 </refsect2> 91 <refsect2 id="gnome-vfs-mime-magic-4-exde-mike"><title>gnome-vfs.mime 92 and gnome-vfs.keys</title> 93 <para>Apart from file sniffing, GNOME also provide a secondary mechanism to 94 determine MIME types. If a file has been sniffed and its type does not match 95 any of the magic patterns, GNOME looks for files called <filename>/usr/share/gnome/mime-info/*.mime 96 </filename> and processes these. The format of these files is different to 97 that of pattern magic. Instead of determining the MIME type by reading the 98 content of the file, the MIME type of the file is determined by its extension. 99 The mime info file has the following format: <screen><computeroutput><replaceable> 100 mime_type</replaceable> 101 ext[,<replaceable>prio</replaceable>]: <replaceable>list of extensions for this mime-type 102 </replaceable> 103 regex[,<replaceable>prio</replaceable>]: <replaceable>regular expression that matches the filename 104 </replaceable></computeroutput></screen></para> 105 <para>More than one <literal>ext:</literal> and <literal>regex:</literal> 106 field can be present for a given MIME type. You can also associate a priority 107 for each field. The default priority (<replaceable>prio</replaceable>) is 108 1, a higher numerical value indicates a higher priority. The indentation before <literal> 109 ext:</literal> and <literal>regex:</literal> must be a tab character (<literal> 110 \\t</literal>). </para> 111 <para>The searching sequence implies that the magic pattern file has a higher 112 precedence over the mime info files. As the mime info files are read alphabetically, 113 this also determines matching orders for the file extension. </para> 114 <para>For example, the file <filename>FirstFile.mime</filename> contains the 115 following definition:<screen><computeroutput>application/foo 116 ext: foo</computeroutput></screen></para> 117 <para>and the file <filename>SecondFile.mime</filename> contains the following 118 definition:<screen><computeroutput>application/mini 119 ext: foo</computeroutput></screen></para> 120 <para>The definition in <filename>FirstFile.mime</filename> will be found 121 first and used.</para> 122 <para>For each MIME info file there must be an associated keys file in the 123 same directory. The key file provides human readable text which can be localized 124 into various languages. The data in these keys files is used by the GNOME 125 file manager, <citerefentry><refentrytitle>nautilus</refentrytitle><manvolnum> 126 1</manvolnum></citerefentry>.</para> 127 </refsect2> 128 </refsect1> 129 <refsect1 id="gnome-vfs-mime-magic-4-exam"><title>&exam-tt;</title> 130 <example role="example"><title>Magic pattern definition for PDF file</title> 131 <para>The following entry in the <filename>/etc/gnome/gnome-vfs-mime-magic 132 </filename> file describes the MIME type of <literal>application/pdf</literal>:<screen><computeroutput> 133 0 string %PDF- application/pdf </computeroutput> </screen></para> 134 <para>The first 5 characters of a PDF file are <literal>%PDF-</literal>. The 135 symbols % and - differentiate the PDF file from a text file.</para> 136 </example> 137 <example role="example"><title>Magic pattern definition for BMP file</title> 138 <para>The following entry in the <filename>/etc/gnome/gnome-vfs-mime-magic 139 </filename> file describes the MIME type of <literal>application/bmp</literal>:<screen><computeroutput> 140 0 string BMxxxx\000\000 &0xffff00000000ffff image/bmp</computeroutput> 141 </screen></para> 142 <para>The interpretation of this line is as follows: <itemizedlist> 143 <listitem><para>The first two characters are <literal>BM</literal> and the 144 seventh and eighth characters are NULL.</para></listitem> 145 <listitem><para>The mask <literal>0xffff00000000ffff</literal> allows the 146 selction of the first, second, seventh, and eighth characters to be selected 147 for comparison.</para></listitem> 148 </itemizedlist></para> 149 </example> 150 <example role="example"><title>MIME info file definition for application/x-compress 151 </title> 152 <para>The following entry in the <filename>/etc/gnome/gnome-vfs-mime-magic 153 </filename> file describes the MIME type of <literal>application/x-compress 154 </literal>:<screen><computeroutput>application/x-compress 155 ext: Z</computeroutput> </screen></para> 156 <para>This line indicates that the <literal>x-compress</literal> application 157 searches for files with a <literal>.Z</literal> extension.</para> 158 <para>The associated keys file entry in the <filename>/usr/share/gnome/mime-info/gnome-vfs.mime 159 </filename> file is as follows (excluding all localized text): <screen><computeroutput> 160 application/x-compress 161 description=compress-compressed file 162 icon_filename=gnome-compressed 163 default_action_type=application 164 category=Packages 165 use_category_default=yes</computeroutput></screen></para> 166 </example> 167 <example role="example"><title>MIME info file definition for application/x-compressed-tar 168 </title> 169 <para>The following entry in the <filename>/etc/gnome/gnome-vfs-mime-magic 170 </filename> file describes the MIME type of <literal>application/x-compressed-tar 171 </literal>:<screen><computeroutput>application/x-compressed-tar 172 regex,2: tar\.gz$ 173 ext: tgz</computeroutput> </screen></para> 174 <para>This example uses the priority flag to give <literal>regex</literal> 175 a higher priority than <literal>ext</literal>, which means that a file with 176 an extension of <literal>tar.gz</literal> should be matched first (to have 177 a MIME type of <literal>application/x-compressed-tar)</literal> before <literal> 178 tgz</literal>.</para> 179 </example> 180 </refsect1> 181 <refsect1 id="gnome-vfs-mime-magic-4-file"><title>&file-tt;</title> 182 <para>The following files are used by this application:</para> 183 <variablelist termlength="medium"><varlistentry><term><filename>/etc/gnome/&cmd;</filename> 184 </term><listitem><para></para> 185 </listitem></varlistentry> 186 <varlistentry><term><filename>/usr/share/gnome/mime-info/gnome-vfs.mime</filename> 187 </term><listitem><para></para> 188 </listitem></varlistentry> 189 <varlistentry><term><filename>/usr/share/gnome/mime-info/gnome-vfs.keys</filename> 190 </term><listitem><para></para> 191 </listitem></varlistentry> 192 <varlistentry><term><filename>/usr/share/gnome/mime-info/solaris-gnome2.0.mime 193 </filename> </term><listitem><para></para> 194 </listitem></varlistentry> 195 <varlistentry><term><filename>/usr/share/gnome/mime-info/solaris-gnome2.0.keys 196 </filename> </term><listitem><para></para> 197 </listitem></varlistentry> 198 </variablelist></refsect1> 199 <refsect1 id="gnome-vfs-mime-magic-4-attr"><title>&attr-tt;</title> 200 <para>See <olink targetdocent="REFMAN5" localinfo="attributes-5"><citerefentry> 201 <refentrytitle>attributes</refentrytitle><manvolnum>5</manvolnum></citerefentry></olink> 202 for descriptions of the following attributes:</para> 203 <informaltable frame="all"> 204 <tgroup cols="2" colsep="1" rowsep="1"><colspec colname="COLSPEC0" colwidth="1*"> 205 <colspec colname="COLSPEC1" colwidth="1*"> 206 <thead> 207 <row><entry align="center" valign="middle">ATTRIBUTE TYPE</entry><entry align="center" 208 valign="middle">ATTRIBUTE VALUE</entry></row> 209 </thead> 210 <tbody> 211 <row><entry><para>Availability</para></entry><entry><para>SUNWgnome-vfs</para></entry> 212 </row> 213 <row><entry colname="COLSPEC0"><para>Interface stability</para></entry><entry 214 colname="COLSPEC1"><para>Obsolete Volatile</para></entry></row> 215 </tbody> 216 </tgroup> 217 </informaltable> 218 </refsect1> 219 <refsect1 id="gnome-vfs-mime-magic-4-also"><title>&also-tt;</title> 220 <!--Reference to another man page--> 221 <!--Reference to a Help manual--> 222 <!--Reference to a book.--> 223 <para> 224 <citerefentry><refentrytitle>nautilus</refentrytitle><manvolnum>1</manvolnum></citerefentry>, 225 <citerefentry><refentrytitle>gnome-vfs.applications</refentrytitle><manvolnum>4</manvolnum></citerefentry>, 226 <citerefentry><refentrytitle>libgnomevfs-2</refentrytitle><manvolnum>3</manvolnum></citerefentry>, 227 <citerefentry><refentrytitle>gnome-interfaces</refentrytitle><manvolnum>5</manvolnum></citerefentry> 228 </para> 229 <para> 230 Latest version of the 231 <citetitle>GNOME Desktop System Administration Guide</citetitle> 232 for your platform. 233 </para> 234 </refsect1> 235 <refsect1 id="gnome-vfs-mime-magic-4-note"><title></title> 236 <para>Written by Ghee Teo, Sun Microsystems Inc., 2003.</para> 237 </refsect1> 238 </refentry> 239