How do filetypes/datatypes work?

Answered
0
0

I know that you can install new “filetypes” on AmigaOS and certain apps can open those files. Any technical info on how this is done?

 

Thanks!

  • You must to post comments
Great Answer
1
0

Update to better answer original question (original very technical answer below).

The Amiga OS datatypes system consists of pairs of files that work together to allow any compatible program to open any file type with an associated datatype installed. One of the pair of files that makes up a datatype is the datatype descriptor, which is placed in DEVS:Datatypes. This is used by the OS to determine the filetype of the file being opened. This file can be removed to disable this datatype, typically by moving to Storage:Datatypes, and the file type will no longer be recognised by applications using the datatypes system. The companion file actually does the translation into a standard file format that the software can read. This file is stored in SYS:Classes/Datatypes. Installing datatypes involves simply copying these two files to their appropriate drawers, and often installation is handled by a standard installer to place the files in the correct locations.

The datatypes system allows applications to open files directly, but to open a file by double-clicking it in Workbench is normally handled by setting the default tool in the file’s icon to the desired application. By default under Workbench versions prior to 3.9, files without an associated icon won’t be opened in any application when simply double-clicked. The DefIcons patch can be added to Workbench 3 to add this functionality and allow files without icons to be opened in an appropriate application which can be set in the DefIcons preferences. Workbench 3.9 and later includes DefIcons as standard.

–Technical explanation of Datatypes system–

Internally, the datatypes system uses an object-orientated model for dealing with external data. This allows a program to deal with information as a general class and not have to worry about the actual format. The standard classes are as follows:

  • Text class. This covers text documents, including formatted and unformatted text.
  • Picture class. This covers all still images.
  • Sound class. This covers all sound data.
  • Animation class. This covers all animated imagery, including optional sound.
  • AmigaGuide class. This covers the AmigaGuide hyperlinked documents.

These are all subclasses of the datatype class, which in turn is a subclass of the Amiga gadget class. Subclasses of each of these classes correspond to particular filetypes, for example the GIF and JPEG datatypes are subclasses of the picture class.

At a simple level, a program only needs to be concerned with the basic class it cares about above. For example, a drawing package need only support loading and saving images using the picture class, and through that it can load and save any image format that has a suitable datatype installed. The datatype translates whatever format the source image is into a standard Amiga bitmap format that the program uses, and provides other information in a standard format, such as image size, number of colours etc.

The dataypes.library contains functions for determining the filetype of a given chunk of data. This task depends on the installed datatype subclasses to identify the data. The datatype descriptor is stored in DEVS:Datatypes and contains the information needed to identify a particular filetype, usually using “magic numbers”, and allows datatypes.library to match it with a basic class. The class itself (stored in SYS:Classes/Datatypes) contains the actual routines for decoding and encoding the data and translating it to and from a standard format supported by the relevant basic class. This system means that it is simple for the user to disable installed datatypes by moving the relevant descriptor from DEVS:Datatypes/ to SYS:Storage/Datatypes and re-enable them by moving them back, without having to touch the installed classes and any associated libraries. Since the descriptor isn’t available, the filetype won’t be recognised and the class won’t be used.

  • Laurent Giroud
    Although this technical description is very accurate it does not really answer the original question which was IMHO about installation of new datatypes rather than how the system works. And if the question was actually about the system technicalities of datatypes then it should probably be rephrased to avoid the confusion.
  • RuThaN
    I think, that he asked, how to assign some application for opening some file format in Workbench by default – by double click.. So, ok we installed datatypes and what next?
  • Daedalus
    Oops, you could be right indeed – I think I misread the question a little! Updating my answer now…
  • You must to post comments
0
0

What you’re asking about are called ‘datatypes’ and inform AmigaOS how to handle files you use, depending on their type/extension.

I nice explanation for this (taken from here) is:

Datatypes lets most newer Amiga programs load any type of file of a format that people have written datatype libraries for. E.g. all image viewers and editors that supports datatypes (pretty much all the were still under development when datatypes where introduced) can load pretty much any image format you can think of without any explicit application support as people are still writing them. Datatypes support also exists for e.g. music, word processing documents and others. For some applications it makes sense to have their own custom filters for some formats, but datatypes provides a minimum level of support for even obscure formats, as well as continued support for new formats for applications that are no longer in development.

Similarly any app that supports XPK can transparently decompress and compress any compression format you drop a library for into the right directory (and in fact there’s a XPK datatype, that if installed lets any application that supports another datatype – such as for images, or documents – support compressed versions of the same).

 

So lets say you want your Amiga and it’s applications to work with .jpg images. I can see from my browser history that I searched “jpg datatype” on aminet.net and was led to this page: http://aminet.net/package/util/dtype/ProDev_jfifdt

I downloaded the lha and installed as directed and now applications that handle images will be able to open jpg files in addition to everything they could previously open.

 

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.