Logo2
Logo
bigstockphoto_Businesswoman_Sit_With_Noteboo_227734
 

Infos

Filetypes

A file is simply stored data. Files can contain executable programs,
text files, pictures or various types, icons for Workbench, or a
multitude of other kinds of data. Most, but not all files, have an
identifiable structure. Directory Opus 5's Filetypes system is
designed to examine a file's internal structure and identify the type
of data it contains. You can configure Directory Opus 5 to
understand an unlimited number of Filetypes.
Filetypes are a powerful feature of Directory Opus 5. By using
Filetypes, you can configure Opus 5 to play animations when they
are double-clicked, to load and use Multiview when you doubleclick
on an AmigaGuide help file, or to uncompress an archived
file when you drag and drop it to a new directory or even to feed
the archive to an external handler such as ArcDir.
This is the essence of the Filetypes; when you do something to a
file, Opus 5 can figure out what kind of file it is, and take the
appropriate action for that type of data.

Predefined Filetypes
Opus 5 comes with some fully defined Filetypes. These are stored
in the DOpus5:Filetypes directory and have both the Filetype
structure fully defined, plus have default commands attached to
the various actions available. The loading of Filetypes is dynamic.
Opus 5 will look to see what Filetypes you have defined in this
directory and load them automatically.
For convenience, we have also provided a set of default Filetypes
definitions in the DOpus5:Storage/filetypes directory. With these,
we have done most of the hard work and have set out the details
needed by Opus 5 to recognise files of the specific types. To use
one of these pre-defined Filetypes, you should use the Automatic
Filetype Creator to identify and install the matching Filetypes or
you can manually drag the required one into the DOpus5:Filetypes
drawer and Opus 5 will recognise and load it automatically. Then,
edit the new Filetype and set out the specific actions you wish to
attach to the new definition. By doing this, you don't have to be
an expert or know anything about the internal structure of the
various files. All you need to do is attach the actions which Opus 5
should take when it recognises a file of this type.

Filetype Manager
The Filetypes requester is accessed from the Settings menu and
displays the list of Filetypes that Directory Opus 5 recognises. For
starters, we have included several definitions. These may include
AmigaGuide, LHA archive, Workbench icons, and Script files.
Your currently defined and available Filetypes will be shown in
the list in alphabetical order. For example,
Add: Allows you to create a new Filetype entry based on a
predefined File Class. When you select this button, two
requesters appear where you may define the actions and
definitions of the new Filetype.
Duplicate: Allows you to quickly duplicate a current entry.
Highlight the desired entry, select 'Duplicate' and a new entry
will be cloned from the current one and presented for editing.
Edit: Displays the Filetype events and allows you to edit the
Filetype definition and command actions.
Remove: Removes a Filetype definition from the list and
deletes the entry from the DOpus5:Filetypes drawer.
Store: Removes a Filetype definition from the list and moves
the entry from the DOpus5:Filetypes drawer to the
DOpus5:Storage/Filetypes draw.

Editing Filetypes
The Filetype Editor consists of a number of parts; one showing the
actual Filetype definition or class, one showing the possible events
or user actions, and one detailing the corresponding commands
each action will perform.
Double-clicking on a particular Filetype, or selecting the Edit
button, displays the list of events or user actions which can be
defined for each Filetype, a special set of menus which you may
attach to the sticky menus for icons of this type, and the default
icon image you wish to use for this type of file.
Events
Each of the actions is associated with either a mouse event or a
limited set of Opus 5 commands, namely User1 - User4.
A tick on the left of an entry indicates that it already has an
Function Command List defined for it. Clicking on an entry in the
list displays the Function Editor, allowing you to edit the
commands associated with this event.
To compare the definitions for multiple events, or edit multiple
definitions simultaneously, double-click on multiple events in
turn. While each of these event types can be defined to do
something different, usually only a few are actually defined. It is
certainly not necessary to define all events for a particular Filetype.
When one of these actions or events occurs, Opus 5 does the
following:-
It first searches the Filetypes list, starting with the Filetype
of highest priority, and checks whether it matches the
entry's Filetype definition.
If it matches, it checks if the corresponding event has been
defined as a notifiable action. If it is defined, it performs
the attached function.
If there is no match for the Filetype definition, or if there is a
match but no associated function, it continues to search the
Filetypes list. Note that it is possible for it to match a
subsequent entry that has a function defined.
Mouse Events
Mouse events occur when you either double-click on a file or when
you drag and drop it into a new directory.
Double-click: This occurs when you double click on a file. A
popular use of this action is to examine a file and, for example,
to show it if it is a picture, or play it if it is a sound. The actual
double-click speed is defined by your Amiga OS preferences.
Drag and drop: This event occurs when a file is clicked on,
dragged to another window and released. One popular use of
this event is for extracting an archive.
Command Events - User 1-4
Command events are called when a file is acted upon by a limited
set of Directory Opus 5 commands. Only the User event
commands are available. The terms User 1, User 2, User 3, and
User 4 may seem cryptic, but they are here to give you flexibility.
Each of the normal Opus 5 commands has an implied usage, but
you may have an application which doesn't really mean any of
these. In that case, you can decide that one of these User events
means "Perform this special operation".
Icon and Filetype Menus
As from Opus 5.5, each icon, and Name mode Listers if activated,
has a special set of Filetype pop-up menus, accessed by pressing
the RMB over the icon, or an entry in a Name mode Lister. Opus
provides a limited set of common commands for these menus
according to the type of icon or file. You can add your own
favourite commands specific to icons and files of defined types.
When an icon is displayed for a file for which you have previously
defined a Filetype, the Filetype menus are added to the pop-up
menus for icons of this type. Select Add to define the Menu label
and functions for your own custom menus.
Default Icon and Select Icon
The Select Icon button allows you to provide an icon image which
Opus 5 will use when displaying this specific Filetype in either an
Icon or Icon Action mode Lister, or when left-out on the Opus 5
Main Window. To add your own special image, either select the
icon image required through the file requester, or drag and drop a
suitable icon into the display area above this button. (We provide
a special DOpus5:Icons directory to store such special icons.)
+ If an icon image is supplied, Opus 5 will use this defined
icon for the internal AddIcon command instead of system default..
Edit Class
Underneath the event list is a button which lets you modify the
class or definition for this Filetype as discussed below.

Definition of a Filetype

Selecting Edit Class from the Event Requester brings up the File
Class editor. Here, you specify the elements which Opus 5 will
look for to recognise a specific Filetype.
Name: This is for the name of the Filetype.
ID: The ID will appear beside the Filetype in the Filetype
manager screen. It is a shorthand way for Opus 5 to display
the name for the Filetype definition.
Pri: The priority determines the order of matching different
Filetypes against the file in question. Generally, it should be
left at zero, but at times it can be very useful or even necessary
to have different priorities.
For example, in the case of having two Filetypes defined,
where one is a subset of the other ( e.g., 24 bit ILBM pictures
versus regular IFF ILBM picture Filetype), you would want the
24 bit IFF ILBM pictures to come first, because they are a
special case of the regular ILBM picture Filetype. Otherwise,
pictures (in this case) will be matched with the regular IFF
ILBM picture Filetype and will never have a chance to match
with the subset 24 bit ILBM picture Filetype. In this case, you
would set the Priority of the 24 bit IFF ILBM Filetype to a
higher priority.
Underneath these fields is the actual script used to perform the
Filetype identification. This is a series of actions that Opus 5 will
perform in order to identify a file of a particular type. The action
may be as simple as matching a filename to a pattern, or ss
complex as scanning an IFF form looking for data in a specific IFF
chunk.
Below the list is a folder gadget, a read only field, and an argument
field. These are used for editing the file identification definition as
discussed below.
Add: Creates a new entry in the file definition script.
Insert: Inserts a new entry in the file definition script above the
highlighted entry.
Remove: Removes the highlighted entry.
View File: Allows you to select a file to be viewed via the
SmartRead command to help you edit the directives used to
match the Filetype.

Editing the Filetype Definition

To edit a line, simply click on it and the read only and argument
fields will be filled in. To change the command in the read only
field, click on the list button and a list of other commands will be
displayed. Select the one you want or press Cancel to abort.
The structure of the Filetype definition script consists of a clause or
a sequence of clauses that describe what should be considered a
matching file for a given Filetype. There are only two directives
that delimit clauses: And and Or. These define what to do if a
clause fails or succeeds. When all the clauses are finished and the
result is true then the file is of the right type.

Edit Commands
And
If the preceding clause succeeds, then also do the following
clause; otherwise skip to the next clause. If the preceding
clause failed, then execution stops and the file does not match.
Or
If the preceding clause fails, then do the following clause;
otherwise skip to the next clause.

Directives
Match text, $hex, %binary or character '\xxx'
States that a sequence of bytes starting at the current file offset
must match the given pattern. Match also supports binary
matching. To match a single unknown character when text is
given, use the '?' character. To match a single unknown byte
when $hex is given, use two of them (??). You can also use
'\000' syntax in text to specify ASCII characters by their
decimal number. A '\009' would be a tab character, a '\114'
would be the lower case 'r'. Use '\063' to match a literal
question mark. Examples:-
Match $000003F3 (executables start with these bytes)
Match FORM????ILBM (the way a IFF ILBM picture starts)
Match Hey\009Overthere ("Hey", a tab then "Overthere")
Match $FFFA (match hex characters)
Match %10110 (match bits)
Match text\127 (match 'text' plus a del character)
Match (NoCase)
Is identical to the Match command but case-insensitive for
ASCII matching (hex, binary and \xxx codes are still case
sensitive).
Match Bits +/- HSPARWED
Tests the file's protection bits. To see if a bit is set, put a +
before the character. To see if the bit is unset use a -.
Example:-
Match Bits +RW (read & write must be on, others
don'tmatter.)
Match Bits -E (executable must be off.)
Match Bits +RW -E (read & write must be on
with executable off.)
Match Comment text
Compare the supplied text string against the comment of the
file. Any valid AmigaDOS wildcard pattern is usable here.
Examples:-
Match Comment Silly_Picture
(a file with 'silly _picture’ as a comment)
Match Comment #?smeg#?
(any file with 'smeg' in its comment field)
Match Date dates
Tests the date of the file against a given date. (See the Select
command on page 122 for information about date strings and
ranges.) Example:-
Match Date 08Sept95
Match Date < 10Jan96
Match Name filename
Matches the given Name pattern against the filename. Any
valid AmigaDOS wildcard pattern is usable here. Example:-
Match Name #?.ilbm
Match Name *.lzh
Match Size > or < or = integer
Tests the size of the file against a value. Example:-
Match Size > 1000
Match FORM
Performs a match for an IFF FORM type. Examples
Match FORM ILBM (match an IFF ILBM picture)
Match FORM SMUS (match an SMUS music file)
Match DT Group
Matches a standard datatype group. This is only available for
OS3.0 and above and the Amiga datatypes.library must have
been installed on your system for this to function correctly.
Examples:-
Match DT Group picture (any picture file known by
datatypes, only first 4 characters are significant)
Match DT Group sound (match any sound file)
For further information, see the Amiga Documentation in
datatypes/datatypes.h for a complete list of current groups.
Match DT ID
Matches a datatypes ID. The datatypes.library must have been
installed on your Amiga for this to function correctly.
Example:-
Match DT ID jpeg (match a JPEG file)
This is dependant on what datatypes you have in your system.
Directory
Matches directories. This command takes no further
parameters. Example:-
Directory (match a directory)

Movement Directives

Move To byte location (in decimal or $hex)
Moves to a specific byte offset from the beginning of the file.
Initially you are always at the beginning of the file, but you
may have been moved in a previous clause, so you might want
to put a MoveTo at the beginning of a clause in order to know
exactly where you are. Examples:-
Move To 0 (back to beginning of the file)
Move To 100 (move to the 101st byte of the file)
Move byte offset (in decimal or $hex)
Moves to a byte relative to the current file offset. Examples:-
Move 16 (move sixteen bytes forward into the file)
Move 4 (move back four bytes from where we are)
Search For text or $hex
Searches (starting at the current file offset) for a certain byte
pattern that matches the given pattern. See the Match
command for valid options to use with this directive. If the
match occurs, then the current file position will be the first
character matched. Examples:-
Search For CMAP (look for 'CMAP', position on the 'C')
Search For M.K. (look for 'M.K.', position on the 'M')
A failure of any Movement directive means that the clause
fails.
One example of usage is for the file class 24bit picture.
Example:-
Match FORM????ILBM (file must start with these
characters)
And (if the previous cause is true then do the following)
SearchFor BMHD (then search for the BMHD chunk ID)
Move 16 (move sixteen bytes into the file)
Match $18 (this must be 24 (or $18 in hex) to be a 24bit
picture.)
Find Chunk
Searches for an IFF chunk. This command is similar to using
Search For but much faster, since it understands IFF file format
and skips non-matching chunks (instead of searching the
whole file). It will also only match real chunk headers,
whereas Search For is always likely to match on erroneous data
in the file when searching for chunk headers. Example:-
Find Chunk BMHD (finds the next BMHD chunk)
+We would suggest that you look at the predefined Filetype
definitions to get an idea of the type of commands to use and
what you can do with this system.

Extra Examples
Some other often used examples are
a) To match a JPEG picture. (You must have jpeg datatype
in your system.)
Match DT Group pict
Match DT ID jpeg
b) To match a 24 bit ILBM picture
Match FORM ILBM
Find Chunk BMHD
Move 16
Match $18
c) To match a GPFax file in FAX IFF format
Match FORM FAXX
Or
Match FORM FAX3
d) To match an AmigaGuide file
Match (NoCase) @database

The Automatic Filetype Creator
We realise that many users do not have time to carefully analyse
files to determine their internal formats. In Opus 5.5, we have
provided a system to automatically test and analyse files and
create the Filetype definition for you. You can also have Opus call
the Filetype creator whenever it fails to recognise a file. This is the
simplest way to build up a list of usable Filetypes quickly.
Unfortunately we cannot create the Command arguments or
functions for you but we have come half way. The rest is up to
you!
The Filetype module is designed to automatically find and create
Filetypes for files or groups of files without the user having to be
an expert on file formats. It provides two internal commands,
FindFiletype and CreateFiletype.
FindFiletype helps you quickly find which of your current
Filetypes match a given file, whether they are actually installed in
the DOpus5:Filetypes or in the storage directory.
The display shows you a list of all the Filetypes that would match
the given file in order of Filetype priority. The Filetype which
Opus 5 would actually use will be highlighted and available for
immediate editing. If a better Filetype is found in the storage
directory than the one currently installed, the Filetype module can
install it for you. If no Filetype is found in either the Filetype
directory or the storage directory it will help you create a new
Filetype by invoking the CreateFiletype command. It also allows
you to edit the current matching Filetype.
 The Filetype Finder only allows you to edit the current matching
Filetype, not all the Filetypes shown in the list. Remember, the Filetype
Finder is designed as a simple interface to help you rapidly indentify
unknown files. For more complicated situations or where you wish to
edit multiple Filetypes, you should use the Filetypes Editor directly.
CreateFiletype helps you to create a new Filetype for a single file
or, preferably, from a list of files of the same type. It is designed to
accept a list of files of similar type, analyse them for common Opus
file matching elements and create a matching Filetype. The
matching elements are displayed on the right of the display and
you may select which specific elements to use to define the
Filetype. If no items show up on the right then the AFC was
unable to find common elements within the selected files. In such
cases, you should selectively delete files from the list until it is
possible to come up with a sensible Filetypes.
From the display, buttons allow you to add and remove files from
this list. You can also simply drag and drop extra files into the list.
To the right of the file list is a series of checkboxes. Each one
represents a standard Opus Filetype matching function. The
functions are:
Name Match Name Match a filename
IFF Match FORM Match an IFF FORM type
Group Match DT Group Match a DataTypes group
ID Match DT ID Match a DataTypes ID
Bytes Match Match bytes
Match (NoCase) Case-insensitive Match
Name: This field shows the trailing part of the names of the
files which match for all selected files. This will usually be the
filename extension such as .gif or .info.
IFF: If all selected files are IFF FORM files and they all have
the same FORM type, this type will be shown here. For
example, ILBM or 8SVX
Group: If the Amiga datatypes system is available on your
machine and all selected files are in the same datatype group,
the group will be shown in this field. For example, 'text' or
'pict'.
ID: If the Amiga datatypes system is available on your
machine and all selected files share the same datatype ID, it
will be shown in this area. For example, 'amig' or 'ilbm' or any
custom datatypes you have installed.
Bytes: This field will show up to the first sixteen bytes of the
selected files using simple pattern matching. The cycle gadget
allows you to enable or disable case-sensitivity.
Only the properties shared by ALL selected files will be shown in
the display. If a file is added to the list which is not of the same
type as those already selected, deleting that file from the list will
update the fields automatically.
Any of these fields may be turned on or off individually.
The Edit button will bring up the standard Opus Filetype Editor
enabling you to customise the match functions as well as adding
default actions, pop-up menus and a default icon. After choosing
the relevant fields by using the checkboxes, you may edit the
Filetype further by hand by clicking on the Edit button.
If you decide to add or remove files from the listview after editing
your Filetype, your edited changes will be lost. A requester will
warn you if this is going to happen.
When a new Filetype is saved, Opus will recognise and use it
immediately.
 You must use the AFC with some thought! It is quite easy to create
a Filetype which is far too general, which matches almost everything. 
After you have created a Filetype, test it with files of different types to
ensure that you have made useful choices.
It is generally not a good idea to use the AFC to make a new Filetype based on a
single sample file only.

FileTypes

The Opus filetype system underpins much of the functionality of Opus. By providing the ability to identify files by a specific type, it allows custom actions when you double-click on a file, press a RMB over a file and so on. For the Magellan-II version we have made a number of refinements and additions designed to provide faster identification of files as well as more control. Many of these
changes are internal.

Others include:-

  • The internal filetypes for Opus configuration files (buttons, environment, etc) have all been moved to priority 125 so they will be matched ahead of user-configured filetypes.
  • A new internal filetype for Start Menus has been added. Double-clicking a start menu will now load it as a start menu and not as a normal button bank.
  • A new internal filetype has been added for Amiga system font preferences files. If you double-click on a system font preferences file, Opus will set its own internal fonts (icon font and screen font if on its own screen) to the settings in the preferences file. (This is complemented by the new LoadFonts command.)
  • Additional filetype actions have been added to the filetype editor. There are six new User actions (along with User1-4 making a total of 10), and qualified double-click and drag&drop actions. The filetype editor window has grown to accommodate these.

The new User actions are accessed via a generic User command, which takes a number as a parameter. This wa done to avoid having to add 6 new commands.

For example, Command User 5 instead of: Command User5

Note that User1, User2, User3 and User4 still work for compatibility.

You can now have filetype actions defined for control and alt drag&drop, and double-click (shift is already used by Opus).The DoubleClick and DragNDrop internal commands have new templates:-

    DoubleClick ALT/S,CTRL=CONTROL/S,NAME/F
    DragNDrop ALT/S,CTRL=CONTROL/S,NAME/F

A new Search Range filetype matching command has been added. This is similar to the Search For command, except that it limits the range of the search. The first parameter on the line is the maximum number of bytes to search. This must be followed by a space, and then by the text to search for as normal. Searching takes places from the current position within the file.

For example,

    Move To 512
    Search Range 1024 hello

This would move to position 512 and then search the next 1024 bytes for the string 'hello'.

A new filetype command, Match Chunk has been added. This is similar to Find Chunk except it only tests the next chunk in the file for a match. It does not search the whole file. This command can dramatically speed up matching of IFF files if you know the order in which chunks appear.

The {Ql} parameter now works when used in a filetype popup menu function. {Ql} also now works through the filetype command system.

It is now possible to add your own separator bars in filetype popups by specifying a label of three minus signs ("---").

The Disk Filetype

There is a new filetype matching command Disk. This allows you to match a disk (similar to Directory for directories). It ca optionally take a filesystem ID to match a specific filesystem, or it can match on device name.

For example,

  Disk matches any disk
  Disk DOS1 matches standard FFS disk
  Disk DOS? matches any DOS disk
  Disk MSD0 matches a CrossDOS disk
  Disk DH3: matches device DH3:
  Disk DF0: will match any floppy in drive 0

Currently, none of the events for Disk filetypes are used, but you can use this to add items to the icon popup menus, and also to set the default disk icon for a particular file system or device.

Normally an icon provided in a filetype will only be used if the disk does not have an associated disk.info icon. The override switch lets you define an icon for a disk type that will override any real icon on the disk if there is one.

For example,

  Disk DF0: override

You can match disk names as well as device names. This is best used in combination with selective priorities to provide the correct matching order.

For example:-

  Disk CD0: override (set to priority 0)
  Disk CD0:CDDA override (set to priority 1)

The first filetype would provide an icon for all data CDs, and the second would provide a different icon for audio CDs only (assuming audio CDs are labelled CDDA by the filesystem).

You may specify a device name using the question mark character '?' as a wildcard

For example:-

     Disk DF?