RISC OS filename translationBy Peter Naulls. Published: 2nd Jan 2004, 21:03:48 | Permalink | Printable
Being understood in the outside worldCompatibility with other Operating Systems has long since been important for all OSes, especially minority ones like RISC OS. A crucial part of this for us is how RISC OS handles filenames compared to the rest of the world. There's been recent discussion about the failing of LanManFS on both Usenet and the Iyonix mailing list, so we thought it might be appropriate to cover these now.
A fully qualified RISC OS filename might be something like:
ADFS::MyRiscPC.$.Documents.Letter (filetyped to text)
But under Unix, it might be:
We're not going to discuss the Windows/DOS format any further, since the issues are much the same, and the Unix format is, by and large, the canonical format for data swapping. However, it's clear that RISC OS and Unix formats differ considerably, and what's appropriate for translation depends upon the circumstance, and there are several we should consider:
- URL file handling
- Filenames over network filing systems (NFS, Samba)
- File handling in RISC OS ports and source files
- Files on ADFS filing systems under Linux
The simple case which applies to all is to simply swap the '.' and '/' characters, and this is reasonably obvious:
|SpriteFile (filetyped sprite)||SpriteFile,ff8|
The last one is slightly unusual - in some cases, it's appropriate to add the ,xxx extension containing the RISC OS filetype to preserve it over systems which don't support this concept.
There is one final issue - Unix filenames usually have everything represented on one filesystem under the root (the "/" directory), whilst RISC OS uses different file systems. Usually this is handled with something like:
URLs in RISC OS
Given the above, and because you've probably seen a file: style URL in RISC OS, the result won't be very surprising. RISC OS browser and web servers will need to peform the '.' and '/' swap. We therefore end up with URLs like:
When fetching remote files, the browser will look at the Content-type header or filename extension and do a MimeMap lookup to set its type.
Network filesystem filenames
This is probably the most contentious topic of the all of them - failure to do it properly will result in lots of frustrated users. Recently, Castle released an update to LanManFS, the Samba client bundled with RISC OS 5. Unfortunately, it had a number of issues, including having an uhelpful default type for untyped files on the host.
The main issue with network filing systems - and there are several for RISC OS, including LanManFS, LanMan98, ImageNFS and SunFish - is the need to have sensible filenames at both ends, and handling of RISC OS filetypes. Some, but not all, of the principles also apply to filename handling in DOSFS/Win95FS filesystems.
In short, it can be boiled down to this - if there's an ,xxx extension on the host filename, then this becomes the filetype presented to RISC OS for the file. If not, the client looks at the filename extension on the host (the bit after the last full stop) - and tries to match that to a filetype using the RISC OS MimeMap functions. If there's no match, or no extension, then it is given the default filetype.
There's also another incidental issue here - some of the miscellaneous ASCII characters that are valid in RISC OS aren't valid on network filesystems, and need to be translated back and forth.
When going the other way, we don't want to needlessly add ,xxx extensions, so if the RISC OS file has an extension which matches its filetype with a mimemap lookup, then no ,xxx extension is added, otherwise it is - the exception is if the filetype matches the default, in which case it is also left unchanged.
One slightly unexpected behaviour with this if you are not familar with the operation is the naming of a typed file on RISC OS which lacks an extension. A JPEG typed file 'picture' in RISC OS becomes 'picture,c85', which may not be entirely helpful in contrast to 'picture/jpg" which becomes 'picture.jpg'.
It's easy to suggest that such files automatically get their extension automatically added. However, this creates problems with reversability, because the filename that gets created is now not identical to what an application expected. To counter this, you might also suggest that file extensions are hidden, and RISC OS is just presented typed files - but again, this causes problems, because we might have several files with the same name, but different extensions. In practice, the best workaround is to make sure you preserve the extension if you plan on trasferring files for use on Windows or Unix.
Finally, what should the default filetype be? The only correct answer which happens to work in all circumstances is text, which is what LanMan98 and SunFish have. Unfortunately, LanManFS has an unhelpful default of the DOS filetype (fe4). On the Iyonix mailing list, I outlined why this would cause problems, which I'll repeat here:
- From a purely syntatical standpoint, it adds nothing. The DOS filetype isn't anything that's usefully used by any RISC OS application.
- On a Unix system, many files lack extensions (are "untyped"). Many of these are in fact textual, and the text filetype is certainly what you want. Most of the remainder are native binary exectuables, and loading into an editor is probably the only sensible thing to do with them on RISC OS.
- Because of the above, creating a new plain file on a Unix share means that the unhelpful ,fff extension is added when all you want to do is create a plain file, so a tedious rename from a shell is required.
- There are numerous (mostly source code) files that certainly are also textual in nature. True, these have extensions, and could be added to mimemap, but there are at least 30 common ones, and these would have to be added to every system, but having the default textual requires no extra effort.
- AOF/ALF files (Acorn C/C++ output notwithstanding) from GCC on RISC OS are filetyped text. It is common to transfer these back and forth to a system where you're cross compiling - again, there are obvious problems here.
- On Windows the tangible benefits of a text default tend to be quite few, although there are certainly limited cases of all that I've listed above. Changing from DOS filetype default emphatically causes no problems at all.
Hopefully the default will be changed in the next version of LanManFS.
File handling in RISC OS ports and source files
For ports of programs from Unix, there are further issues. Many programs assume Unix style filenames, or their config files have Unix style filenames in them. Sometimes ports can be modified to use RISC OS filenames instead, and often this is preferrable. In other cases, the handling is deeply embedded, or just not worth the effort to change, especially when we're talking about lots of different ports.
Fortunately, Unixlib comes to the rescue, and at all places where a filename is passed to RISC OS, it goes through a translation function, which performs the types of translations previously discussed, and many others. The behaviour is configurable, and is also very complex to deal with many cases that we don't have room to discuss here. One for example which is on by default is to set the RISC OS filetype based upon the extension with a mimemap lookup.
For most ports, the default behaviour works fine, but there might need to for further code to translate RISC OS names to Unix ones (and Unixlib provides another function for this) at the point that filenames are passed to a program. It is sometimes neccessary to switch the translation on and off, which is entirely possible.
One special case, which is also dealt with by Unixlib, is source filename handling, in particular, C source files. For historical reasons relating to the old 10/77 limitations on RISC OS, and now something that is still used for convenience, C header and source files are stored in their own 'c' and 'h' directories under RISC OS.
This means that 'program/file.c' under Unix is 'program.c.file' under RISC OS. In some cases, it is even required for Unixlib to create a new directory before a file can be created. The extensions for which this happen are configurable, but for GCC, it applies to about 20.
Sometimes these files Unix format filenames for source files need to be translated to RISC OS ones when files are unpacked from a Unix archive. One program than can do this automatically without lots of tedious renaming is my program, Reverser.
Files on ADFS filing systems under Linux
There is one final interesting case. As you may know, it is possible to read ADFS filing systems under Linux. Sometimes it is useful to know the filetypes, especially if you're also exporting this filesystem over Samba or NFS to be subsequently read with a RISC OS client.
In this case, the solution is to always append the ,xxx filenames extracted from the ADFS filesystem. There is no gain in this instance of being choosy about when to add the extension. When saving files, the ,xxx extension is stripped and its filetype set. When there's no extension, fff is used. However, this is slightly academic, as ADFS saving is not fully implemented under Linux.
Hopefully, this has cleared up some confusion (and quite possibly generated some more). We'd be interested to hear about any related issues that weren't answered.
Previous: New RISC OS news site opens
Next: tofla moves to iconbar.com
DiscussionViewing threaded comments | View comments unthreaded, listed by date | Skip to the end
Please login before posting a comment. Use the form on the right to do so or create a free account.
Search the archives
Today's featured article
How to get your favourite old games running on your newer hardware
Alex Macfarlane Smith guides us through the patchwork
Discuss this. Published: 22 Jan 2003
drobe.co.uk pilfers elusive Omega
Mine! All mine! And we have the photos to prove it
17 comments, latest by EPDM on 3/4/03 12:07AM. Published: 30 Mar 2003
News and media:
RISCOS Ltd •
RISC OS Open •
MW Software •
Advantage Six •
CJE Micros •
Liquid Silicon •
Chris Why's Acorn/RISC OS collection •
The Register •
The Inquirer •
Apple Insider •
BBC News •
Sky News •
Google News •