File Types
General Info Various functions in BarNone can use a file's type. For example, a DropCmd object can call different commands depending on the type of a workbench icon dropped on it.

A file type might be, for example, a jpeg bitmap, a gif bitmap, a C program file, an IFF sound file, and so on. File types are matched with a short identifying string. It has become popular with MIME to use slash separated strings for these identifiers. For example:

    image/jpeg
    image/gif
    text/plain

and so on.

Determining File Type BarNone offers several algorithms for determining a file's type. They are:

  • Match File Name (Ignore Case)
  • Match File Name (Match Case)
  • Match File Contents (Binary)
  • Match File Contents (Pattern)
  • Match Directory Name (Ignore Case)
  • Match Directory Name (Match Case)
  • Ask External

When required to find a file's type, BarNone searches through each of the rules defined in the File Types list in the main editor window in turn. The first rule that succeeds determines the files type. For example, if there are two entries that match a file's name:

    file/f   (*.f)
    file/g   (*.g)

then a file named afga would be classified as file/f.

There are several example types included in the Objects/FileTypes directory. These can be loaded by using the Insert... button.

Match File Name (Ignore Case) A straightforward match of a file's name, ignoring case. Any valid AmigaOS pattern may be used. It is generally better to match a file's contents, if possible. Most formats have fixed identifier bytes near the beginning of the file to permit a contents match.
Match File Name (Match Case) Similar to the above, but upper/lower case must match.
Match File Contents (Binary) The Pattern attribute is a description of a short segment of the file's contents, in ASCII or hex. The following may be included, and must be separated by one or more spaces:

  • The keyword Offset (case sensitive), followed by a colon, followed by an offset specify a byte position in the file. This offset may not be greater than 100 bytes. For example:

      Offset:6

  • The string 0x, followed by one or more hex characters. For example:

      0x00ab91

  • One or more more 8 bit printable characters.
The hex or printable characters must match the file contents at the indicated offset. For example, to match a JPEG file, one might use:

    Offset:6 JFIF

Which will match any file with the string JFIF 6 bytes into the file.

Match File Contents (Pattern) The contents of the file are read in their entirety, looking for a line which matches the given pattern. Note that this will happen for binary and text files alike. The results for binary files may be unpredictable.
Match Directory Name (Ignore Case) Similar to Match File Name (Ignore Case) but for directories.
Match Directory Name (Match Case) Similar to Match File Name (Match Case) but for directories.
Ask External A last resort. The pattern gadget specifies the name of a program to execute. This file will be given one parameter: the name of the file. It must produce one line on its standard output, which will either be empty (a newline) if the program could not identify the file, or a description string.

Note that the program must produce one line of output. The PIPE: device is used to read the output from the program and must be mounted.