## File Type Plug-ins

File Type Plug-ins — Plug-in loading and/or saving third party data formats.

## Registration

When the plug-in is called with `register` as its first argument it should dump following information to standard output (each on a separate line) and terminate:

- plug-in name
- file format description
- file globs
- supported operations

These information correspond to similar file module information. All fields are case-sensitive. The supported operations line consists of a space-separated sublist from:

`load`
`save`

The file globs line consists of a space separated list of file globs (not just extensions; note to Unix users: they are in fact GPatternSpec globs, so character classes are not supported) of files the plug-in claims it can read and/or write. Note the plug-in proxy has a notion of file glob specificity and prefers to give chance to the plug-in whose file glob is the most specific if more than one match. So while it is possible to register `*.*` the effect is quite the opposite of getting all files Gwyddion tries to open or write.

So the output of plugin acme_v5 when run as acme_v5 register could look:

    1
    2
    3
    4

    acme_v5
    ACME AFM Data Format v5 (*.ac5)
    *.ac5 *.acme5
    load save

## Loading

When the plug-in is called with `load` as its first argument then the second argument is the name of dump file to write the data to, and the last, third argument is the name of the file to load.

The plug-in reads the specified file and dumps the data to the dump file. The dump file is created as an empty file before the plug-in is run to avoid race conditions. The plug-in should just overwrite with actual data. Leaving the dump file empty is a mark of failure to load the given file.

## Saving

Saving works much like loading. When the first argument is `save`, then the second and third arguments are again names of dump file and the file to save (the order of arguments is the same as in loading, dump file always comes first, then the real file).

The plug-in reads the dump file and writes the data to the file given as the last argument. Since the file to be written can already exist the only reliable signal of failure to save the file is returning nonzero exit code.