|
|
| Beta! | About us | Contact | RSS | Webspace | Tech docs | Downloads | BBC Micro | Gallery | Wallpaper |
|
RISC OS filename translation By Peter Naulls. Published: 2nd Jan 2004, 21:03:48.Being understood in the outside world Compatibility 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.The Issue A fully qualified RISC OS filename might be something like: ADFS::MyRiscPC.$.Documents.Letter (filetyped to text) But under Unix, it might be: /home/peter/documents/letter.txt Or Windows: C:MyDocumentsletter.txt 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:
Simply Put The simple case which applies to all is to simply swap the '.' and '/' characters, and this is reasonably obvious:
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: ATAFS::Erble.$.Internet.!Nettle Becoming: /ATAFS::Erble/$/Internet/!Nettle/ 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: file:/ATAFS::Erble/$/Programming/SDL/SDL12/docs.html 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:
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. Finally 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. Discussion Viewing threaded comments | View comments unthreaded, listed by date
Please login before posting a comment. Use the form on the right to do so or create a free account. |
Login
Create a new account Forgot your password? Search this website
Featured articles News from the event in the south of the UK 42 comments, latest by diomus on 9/11/08 8:45PM. Published: 19 Oct 2008Four uni coders lined up to improve web browser 33 comments, latest by rjek on 27/04/08 1:01PM. Published: 21 Apr 2008Martin Hansen runs through a few useful desktop tricks you may not be aware of 14 comments, latest by DS1 on 27/3/08 1:13PM. Published: 22 Mar 2008Useful links News and media:Iconbar • MyRISCOS • ArcSite • RISCOScode • ANS • C.S.A.Announce • Archive • Qercus • RiscWorld • GAG-News Top developers: RISC OS Open • RISC OS Ltd • MW Software • R-Comp • Advantage Six • VirtualAcorn Dealers: CJE Micros • APDL • Castle • a4 • X-Ample • Liquid Silicon • Webmonster Usergroups: WROCC • RONE • NKACC • IRUG • SASAUG • ROUGOL • RONWUG • MUG Useful: RISCOS.org • RISCOS.info • Filebase • NetSurf Non-RISC OS: The Register • The Inquirer • Apple Insider • BBC News • Sky News • Google News • xkcd • diodesign |
Recently logged in:
Monty •
druck •
Stoppers •
DaveW •
hubersn •
sa110 •
wrankin42 •
rjek •
bucksboy •
diomus • Stats
© 1999-2008 The Drobe Team. Some rights reserved, click here for more information | Powered by MiniDrobeCMS, based on J4U
"It does appear that inaccuracy is drobes [sic] house standard at the moment"
Page generated in 0.1642 seconds.