Internet media types (MIME types) for retro file formats?

You can talk about almost anything that you want to on this board.

Moderator: Moderators

Post Reply
TrevorGage
Posts: 1
Joined: Wed Mar 04, 2020 2:27 am

Internet media types (MIME types) for retro file formats?

Post by TrevorGage » Wed Mar 04, 2020 2:32 am

I just had a conversation with the maintainer of j0CC-FamiTracker in the FamiTracker users' Discord server. It turns out that the Android operating system relies on media types (also called MIME types), not filename extensions, for routing "intents" (structured command lines) to applications. I've discovered that the "Open With..." functionality of the Downloads list in Firefox for Linux also depends on media types, as a file served as application/octet-stream consistently opens in the wrong application.

So are there widely used media types that correspond to common filename extensions used by software targeting old Nintendo platforms?

These might be in application/*: .nes, .sfc, .gb/.gbc
These might be in audio/*: .nsf, .ftm/.0cc, .spc, .gbs

If not, it might be time to write some authoritative format docs and register the media types with IETF.....
Last edited by TrevorGage on Wed Mar 04, 2020 10:51 pm, edited 1 time in total.

tepples
Posts: 21980
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Internet media types (MIME types) for retro file formats?

Post by tepples » Wed Mar 04, 2020 7:18 am

On Debian and Ubuntu, the libfile-mimeinfo-perl package provides /usr/bin/mimetype and the file package provides /usr/bin/mimetype. Debian 10 "buster" provides these versions of the programs:

Code: Select all

$ file --version
file-5.35
magic file from /etc/magic:/usr/share/misc/magic
$ mimetype --version
mimetype 0.29

Copyright (c) 2003, 2012 Jaap G Karssenberg. All rights reserved.
This program is free software; you can redistribute it and/or
modify it under the same terms as Perl.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
But they don't always agree on what they recognize:

NES ROM

Code: Select all

$ file pently.nes
pently.nes: NES ROM image (iNES): 1x16k PRG, 1x8k CHR [V-mirror]
$ mimetype pently.nes
pently.nes: application/x-nes-rom
NSF audio

Code: Select all

$ file pently.nsf
pently.nsf: NES Sound File ("Pently demo" by DJ Tepples, copyright 2019 Damian Yerrick), version 2, 24 tracks, NTSC
$ mimetype pently.nsf
pently.nsf: application/octet-stream
Super NES ROM

Code: Select all

$ file lorom-template.sfc
lorom-template.sfc: data
$ mimetype lorom-template.sfc
lorom-template.sfc: application/vnd.nintendo.snes.rom
Super NES audio

Code: Select all

$ file lorom-template.spc 
lorom-template.spc: SNES SPC700 sound file, version 0.30, with ID666 tag, song "Selnow", game "Pino's LoROM template"
$ mimetype lorom-template.spc
lorom-template.spc: application/x-pkcs7-certificates
Game Boy program

Code: Select all

$ file ../240p-test-mini/gameboy/gb240p.gb
../240p-test-mini/gameboy/gb240p.gb: Game Boy ROM image: "144P TEST" (Rev.00) [SGB+CGB] [ROM ONLY], ROM: 256Kbit
$ mimetype ../240p-test-mini/gameboy/gb240p.gb
../240p-test-mini/gameboy/gb240p.gb: application/x-gameboy-rom
Game Boy Advance program

Code: Select all

$ file gsmsongs.gba
gsmsongs.gba: Game Boy Advance ROM image (, Rev.00)
$ mimetype /home/pino/Dropbox/tunes/mrmister.gba
/home/pino/Dropbox/tunes/mrmister.gba: application/x-gba-rom
FamiTracker modules

Code: Select all

 file moonlight_sonata.ftm 
moonlight_sonata.ftm: data
$ mimetype moonlight_sonata.ftm 
moonlight_sonata.ftm: application/x-wine-extension-ftm
$ file Arpeggio_Waltz_0_12_scheme.0cc
Arpeggio_Waltz_0_12_scheme.0cc: data
pino@pinox61:~/Dropbox/tunes/my_chip$ mimetype Arpeggio_Waltz_0_12_scheme.0cc
Arpeggio_Waltz_0_12_scheme.0cc: application/x-wine-extension-0cc
Interestingly, for all but the .nsf, mimetype returned a type even for a nonexistent file. This means it must be matching based on extension.

zzo38
Posts: 1064
Joined: Mon Feb 07, 2011 12:46 pm

Re: Internet media types (MIME types) for retro file formats?

Post by zzo38 » Sat Mar 07, 2020 9:37 am

tepples wrote:
Wed Mar 04, 2020 7:18 am
On Debian and Ubuntu, the libfile-mimeinfo-perl package provides /usr/bin/mimetype and the file package provides /usr/bin/mimetype.
It is easy to see, some of these MIME types are incorrect, presumably because another file format uses the same extnsion (for Super NES audio), or it is unknown (NSF audio), and I am guessing that "x-wine-extension" is used for loading Windows-based files from a Linux-based file manager (although I don't actually know). So, in some cases, a suitable MIME type already exists; in some cases, it does not (at least in the Debian mimetype package; maybe a suitable MIME type is defined elsewhere, in which case you should contribute the correct ones to Debian).

In some cases there might be a use to add parameters to denote some information, although they are mostly optional and can be determined by the contents of the file so are not strictly needed. Such information may include the mapper number (so that you may indicate the mapper number before downloading the file, if wanted). There may be some cases where due to historical reasons some details cannot be determined easily from the contents of the file, though (I think some GameBoy ROM files specify an incorrect mapper number in the header (in the case of NES this is not a problem since it can be corrected); I also believe this to be the case for some very old Amiga MOD music files).
[url=gopher://zzo38computer.org/].[/url]

Post Reply