Worker file manager

1. File type system

1.1. File type name

The file type name will be shown in the corresponding list view column. It can be any string and it can also contains flags which are replaced by dynamic data. As for now, the only flag supported is "{mimetype}" which is replaced by the mime type reported by the libmagic library. This is basically the same as executing the tool

file --mime-type ...

The unknown file type in the default configuration uses the name "ukn({mimetype})" which results in something like "ukn(text/plain)".

1.2. File type definition

Worker uses a file type hierarchy to describe the file types. This means that it is possible to group similar file types together. For example different image formats can be grouped into one "Image" type so the program to display the images only needs to be defined once.

Also, file type priorities can be used so that more generic file types don't match if a more specific file type matches.

The file type itself can be described in four different ways which are described in the following.

1.2.1. Match file name by pattern

The easiest way is to enter a pattern for the file name (for example "*.png"). You can choose to ignore the file name case and to match the complete file name (in contrast to just the base name). The pattern can contain the wildcard "*" to match any string. You can also select to match the name with regular expression. If regular expressions are not used, you select an option to use multiple patterns, separated by commas.

1.2.2. Match by content

A better way to describe a file type is to use part of the file content. Even files without an extension or a different (potentially wrong) extension can be recognized correctly. However, this needs knowledge about some common bytes of the file type. You can enter these bytes directly or use a list of files and let Worker try to find common bytes. This method is very fast in comparison to the next method.

1.2.3. Match with libmagic

You can also utilize the "file" database from libmagic to detect the file type. In the configuration section you can select a file to see the output of libmagic. The actual pattern can contain the wildcard "*" to match any string.

Available options are:

1.2.4. Advanced matching

The advanced method allows the use of definitions of an expression. You can use boolean operations to combine several sub-expressions which includes tests for file content, tests for file name patterns or even tests for the output of external programs.

1.3. File type recognition

The file type recognition takes the file type hierarchy into account. Worker starts checking the type of a file at the root of the hierarchy. If the file matches any defined tests of a file type description, Worker checks the child types so the best match in the file type hierarchy is used.

Example: A root file type "executable script" could check if the file starts with "#! /" while any child type checks for additional information like "/bin/sh" for a shell script. This way files without "#!" at the beginning will not be checked for any child type.

In addition, file types with a higher priority (i.e., a smaller priority value) will win over a file type with a lower priority, if both would match for a given file. When using the file type hierarchy, the priority values of child types are added to the parent file type for the actual priority value. In the example above, if the root file type "executable script" has the priority value of -10 and the sub-type "shell script" has the priority value of -10 too, the actual priority value for the "shell script" is -20, so it would win over another matching file type with a value of -19 or more.