Filetypes
Chris Hall (132) 3558 posts |
An application that will run a (newly defined) filetype can define the file type icon and the desired double-click and shift-click run action in the !Boot and !Run files within the application. Obviously the file type has to be registered with ROOL so that noone else uses it. I should like there to be a way that the application’s !Boot and !Run files can register the filetype with Mimemap as well: then attachments sent by email will appear correctly the other end and will appear correctly when received so that the attachment can simply be double clicked on. Also saving them from RISC OS onto a NAS will simply save the plain filename (e.g. textfile/txt’ rather than ‘textfile/txt,fff’). Is the Mimemap format defined anywhere? It seems rather obscure when you look at the various entries. Simply registering the filetype with ROOL does not succeed in getting Mimemap updated except after geological time. |
Dave Higton (1515) 3534 posts |
As far as I understand it, there is not One True Version of the Mimemap file. Follow-up questions to your suggestion might include whether this would be desirable or even possible.
Does it have to be done from the !Boot and/or !Run files? How about a Mimemap updater app that can add an entry, after checking that it doesn’t already exist, and is run once by the user on installing the client app? The updater could also find and display details of existing entries. It would be possible for a client app’s !Boot (or even !Run) file to call such an app, but, since the change to MimeMap normally only needs to be made once, I’m not convinced that I’d like client apps to be spending time checking Mimemap every time they boot or run. I take your point about the desirability of something better than we have now (i.e. manual editing, which is daunting for many and error prone), but I see the solution a bit differently. |
Rick Murray (539) 13850 posts |
Should perhaps be added to the list manually in the !Boot file. |
GavinWraith (26) 1563 posts |
I have a small utility, !MiMerge, for merging MIMEmap files, which I wrote in 2013, in case anybody is interested. |
Dave Higton (1515) 3534 posts |
I’m interested, but I can’t see it on your web site. |
GavinWraith (26) 1563 posts |
I have just put it here . |
Chris Hall (132) 3558 posts |
Should perhaps be added to the list manually in the !Boot file. I agree the ‘run action’ and ‘edit action’ have to be in the !Boot or !Run file of every application (as at present) that knows how to deal with that filetype. However the Mimemap definition and the filetype icon will be needed irrespective of whether the application has been seen or whether such an application has ever existed. For example .xlsx files cannot be handled by any RISC OS application but do have a Mimemap entry. Not sure whether they have a filetype icon yet though. Another example is .kml files which can be handled by a RISC OS application (!RiscOSM) but have no mimemap entry, no filetype icon and no run action defined. Also .kmx files which can be handled by a RISC OS application (SparkFS) but have no run action specified. Also .docx files which can be opened by SparkFS but are not recognised as an archive file type by SparkFS. |
Gwyn (355) 46 posts |
I thought Luafox could handle xlsx files |
Chris Hall (132) 3558 posts |
I thought Luafox could handle xlsx files I don’t have this but my point is that .xlsx attachments to e-mail messages and the filetype icon should still be defined even if the relevant application is not present or does not exist. Another one is .eml files (type &b86) which currently have no mimemap entry and I don’t know how to create one (syntax for mimemap entries doesn’t seem to be defined). |
Mike Freestone (2564) 131 posts |
In the mimemap on rc14 at least, the format is described in the top 12 lines of the file which looks fairly easy to follow to me |
Chris Hall (132) 3558 posts |
It’s not defined at all. The filetype .ico (&132 ‘ICO’) is described as ‘image/vnd.microsoft.icon’ – how does one guess a plausible description like this? There’s ‘application/msword’ for .doc so one could guess ‘application/msexcel’ for .xls and ‘application/msexcelx’ for .xlsx and add an item but (a) how does one know whether it is correct (what test can one do?) and (b) if not then what? Also what command should one add in an application’s !Boot file to check whether a mimemap entry exists for a particular filetype and, if not, add it to the pool? |
Steve Fryatt (216) 2105 posts |
You don’t guess; you look it up in the list of defined MIME types, just as you presumably looked up the RISC OS type &132. As a starting point, try http://www.iana.org/assignments/media-types/media-types.xhtml |
Steve Pampling (1551) 8172 posts |
Which brings you to, as an example, the MIME type information for xls being: or as in the MIMEMAP file not sure why Chris guessed ‘application/msexcel’ for .xls when the actual (slightly different) version seems to be in the existing mimemap file. |
Chris Hall (132) 3558 posts |
Many thanks for this. How do I add a mimemap entry to the pool (if not already there) when a particular application starts or is seen by the filer – what command do I have to add (similar to the RMEnsure) that checks for a particular Mimemap entry and, if not there, adds it in? That is the item for my wish list. My ARMX6 does not have a mimemap entry for .xls but I suspect that might be my fault. |
Sprow (202) 1158 posts |
The short answer is you can’t, but this is the wishlist forum! The longer answer is that historically every filing system that might encounter DOS extensions carried round its own method of turning those into RISC OS filetype (for example, the deprecated *DOSMAP command). That became an unworkable solution, having to do the same thing for each FS, so things started to move over to looking them up in the MimeMap. There are still some vestiges of the old scheme hanging around: CDFS has a table of 9 built in entries, and LanManFS has 6 to fall back on if there’s no MimeMap loaded. The problem with the MimeMap is that it’s not designed for that as its primary purpose. If you look at it you’ll note it’s a one-to-many database because many Mime types and extensions can map to one filetype. For example: the audio file extension “.aif” maps to &FC2. But &FC2 maps to “.l16” too and “.aiff” and “.aifc” and 3 corresponding Mime types. Or if you lookup “.jpeg” and get &C85, but if you then ask what the extension for &C85 is you’ll get “.jpg”. There are a few technical problems under the bonnet too just to make things more muddy, the file is parsed in the order it is written, so lookups (and more importantly reverse lookups) depend on the order entries are added rather than their relationships or priority. The file is currently organised with the IANA entries first to take advantage of this, but it prevents things like hashed lookups internally because as soon as you sort the list it no longer makes sense. Or what to do in the event of a conflict. So I’m not sure how to programmatically (like a *command or some kind of dedicated editor) add entries at runtime. The file itself should probably be considered a read only OS resource, in the same way that nobody’s editing their Protocols database (in the same directory) on a daily basis either. I did have a look how other OS’ handle Mime mapping a while ago and they also struggle with a way to represent the authoritative entries from the home brew. For the time being you’re stuck with hand inserting an entry.
Sounds like you missed an update, it’s there in the ROOL disc image. |
Jeff Doggett (257) 234 posts |
Or the *FAT32MAP command in Fat32fs.
CDFS also has an environment variable CDFSNewFileTypePath$File which allows it to load a whole file of mappings. Fat32fs also reads this variable & file. |
Chris Hall (132) 3558 posts |
The short answer is you can’t, but this is the wishlist forum! Thanks for a comprehensive and clear answer. As you say, this is the Wish List forum! |
Chris Hall (132) 3558 posts |
You don’t guess; you look it up in the list of defined MIME types, just as you presumably looked up the RISC OS type &132. As a starting point, try http://www.iana.org/assignments/media-types/media-types.xhtml It does not seem to have an entry for .doc files (Microsoft Word) for example or indeed any filename extensions. What I need is a look up table for the Windows .xxx filename extensions to see which MimeMap definition to use for them. |
Chris Evans (457) 1614 posts |
LanMan98 will use the OS’s MimiMap if it can see one. If not it has its own one. |
Steve Pampling (1551) 8172 posts |
Paraphrase “Highlander” – There should be only one. |
Vince M Hudd (116) 534 posts |
In that case, has something changed somewhere down the line? The current version of WebChange (the main bulk of which was written on an Iyonix) uses MimeMap to map filetypes and extensions – but it uses an internal (user expandable) list of its own to map long (4+ character) extensions to short (3 character) extensions. The two included by default being html/htm and jpeg/jpg. The relevant file (WebChange.ShortExts in Choices) says: # Long/Short Extension mappings file for WebChange # Use LongExt=ShortExt on each line # WebChange will use the MimeMap module to get an extension from a filetype # And if asked to use short extensions, will look here for a translation # (Mimemap returns the long extension by default - it would be nice if it # would supply the caller's choice, but we take what we're given and make # the best of it). html=htm jpeg=jpg
I don’t yet have the DDE set up on the Iyonix, because I can’t find my card reader (the last version I bought was on an SD card – which I probably won’t be able to find either!) New ‘bug’ will have to wait. 1 There is already an alternative workaround – a script can be run to rename */jpg to */jpeg – but I’d like the actual menu entry to work. |
Chris Hall (132) 3558 posts |
I have added the following lines to my Mimemap file after the entry for Microsoft Word files (in Internet.Files):
They seem to work (except that I do not have a filetype icon for A7F (xlsx) files). |