The MimeMap module

The MimeMap module provides a central service for mapping between RISC OS file types, MIME content types, 'dot' extensions and Mac filetype/creator pairs.

When the module is loaded it reads the file <Inet$MimeMappings> and stores the parsed file internally. If the system variable is changed, or the module is explicitly told to, the old version will be discarded and the file parsed again.

The MimeMap module can handle 5 different file typing schemes:

  • RISC OS file type by number, eg &FFF
  • RISC OS file type by name, eg Text
  • MIME content type string, eg text/plain
  • File extension string, eg .txt
  • Mac type/creator pair, eg "ttxtTEXT"

Any type can be converted to any other type.


MimeMap_Translate (SWI &50B00)
On entry
   R0 = Input format
   R1 = Input data or pointer to buffer
   R2 = Output format
   R3 = Pointer to output data buffer (if needed, 128 bytes)
On exit
   R0-R2  Preserved
   R3 = Result, or output buffer pointer

This SWI is used to access the mapping translation database to convert from one type format to another.

The 5 formats supported are:

     #    Name                            Meaning
     0 MMM_TYPE_RISCOS               RISC OS file type passed as an int
     1 MMM_TYPE_RISCOS_STRING        RISC OS file type passed as a pointer
     2 MMM_TYPE_MIME                 MIME content type passed as a pointer
     3 MMM_TYPE_DOT_EXTN             File extension (no dot) as a pointer
     4 MMM_TYPE_MAC                  Mac type as a pointer


   *MimeMap [ &<hex> |
         .<extension> |
         <major>/<minor> |
         <typename> |
         "Mac_Type" ]

This command is used to read the mime file or display the translation of certain types. If issued with no parameters it will list all the known types. Alternatively, it can be followed by the type names as used in the types file :

  • a type name &xxx to map a RISC OS file type in hexadecimal
  • .ext to map a file name extension
  • major/minor to map a MIME content type
  • a simple string to look up for a RISC OS file type
  • a Mac type pair in quotes

This command causes the MimeMap module to re-read the mappings file.

Mac type names

Mac types are specified in the form: "XXXXxxxx" where XXXX is the filetype and xxxx is the vendor type. ? can be used as a single character wildcard. \? means a literal ?. \t, \v, \n, \r have their usual meanings. \DD (where DD are 2 hex digits) represents the character with ASCII code &DD.

There is a default Mac mapping defined, where "&DDDAcrn" maps to filetype &DDD (for hex digits DDD). This vendor name is registered with Apple. Within Mac mappings, the least number of wildcards is matched if multiple matches are possible.

Mac mappings must be enclosed in double quotes (") when passed to the *MimeMap command, and in the MimeMap file.

File format

The MimeMap file is split into 5 fields to provide the type mappings database. Entries within the file are searched in the same order in which they appear, with wildcards matched last. Fields are tab delimited, and consist of :

 <mimetype> <tab> <ro-text> <tab> <ro-hex> <tab> <extensions> <tab> <mactype>

  <mimetype> takes the form of <major>/<minor> types as defined by IANA.
  <minor> may be a '*' wildcard to match anything with the <major> type.
  <major> may be a '*' wildcard to match any type.
  <ro-text> is the textual form of <ro-hex>.
  <ro-hex> is the hexadecimal RISC OS type.
  <extensions> is a period (.) prefixed, tab separated list of file extensions.
  <mactype> is a Mac type/creator pair as described above.

This documentation is copyright 3QD Developments Ltd 2013 and may not be reproduced or published in any form without the copyright holders permission. RISC OS is subject to continuous development and improvement as such all information is reproduced by 3QD Developments Ltd in good faith and is believed to be correct at the time of publication E&OE. 3QD Developments Ltd cannot accept any liability for any loss or damage arising from the use of any information provided as part of the RISC OS Documentation.

HTML document version 1.03 3rd November 2015