Adding datatypes to the system

A datatype can be defined using a normal text-editor. Like already mentioned datatype files are normal text files containing a JSON structure. Adding support for a new file-type takes only a minute, and you don’t need any programming skills to do this.

Here is the text.datatype file, this teaches the system to recognize text files:

{
  "Identifier": "BF04CD30-7C28-48DC-92D4-F1A3A224D0A6",
  "SelectedIcon": "res\/icons\/textfile.selected.png",
  "UnSelectedIcon": "res\/icons\/textfile.normal.png",
  "Description": "Common textfile format",
  "TypeName": "textfile",
  "MimeType": "text\/plain",
  "FileExt": ".txt"
}

Let us go through the fields one by one

Identifier

This field should include a unique identifier. The system will generate a GUID for the system’s default types, but you are free to use any identifier as long as it is unique and uses JSON compatible characters.

SelectedIcon

Populate this field with a link to the icon for the file in selected mode. This should be how the icon looks after you have clicked on it. Typically the selected and normal icon are somewhat different. If you only have one icon, use the same in both selected and unselected fields.

UnSelectedIcon

Same as the selectedicon field, but here you define the normal, unselected graphic. Again, if you only have one icon, use the same in both selected and unselected fields.

Description

A brief description of the datatype. Try to make it fast to read yet as beneficial as possible. Here are a few examples:

  • common text file
  • portable network graphics
  • mp3 compressed music file

TypeName

This field is very important since it touches on category. Human beings like to bundle similar items into groups, like “music files” and “picture files”. The list of categories the system supports is growing – but as of writing the following type-names can be applied:

  • textfile – txt, doc, rtf ..
  • soundfile – wav, snd, rif ..
  • musicfile – mp3, ogg ..
  • moviefile – mp4, mpg, avi ..
  • scriptfile – run, lua
  • imagefile – png, jpg, bmp, iff, gif, tif ..
  • archivefile – zip, rar, tar ..
  • linkfile – lnk (shortcut files)
  • setfile – set
  • layoutfile – layout, used in folders for customization
  • sourcecode – pas, c, cpp, bas, js, php ..
  • executable – url, exe

Note: the system auto lower-case the value of this field(s), so lowercase or uppercase has no effect. It will default to lowercase so you should stick to that, but nothing bad will happen if you don’t.

Mimetype

Where “typename” places a file or datatype in a broader category, mimetype is where things get more specific. This is the type that must be declared when a file is moved over the network (for instance when your browser downloads a file, the server must include the mimetype so your browser knows what to expect).

Here I will refer you to the official mimetype standard as defined in RFC 2045. A list of common mimetypes is also included:

Should your file lack any official mimetype, use application/octet-stream, which informs the system that the file should be treated as binary and that no form of filtering should be applied.

FileExt

This is by far the simplest field of them all, namely the file-extension or “last name” for the file you are adding to the system. As explained previously in this chapter we use the same file scheme as Microsoft Windows and expect your files to have last names.

Again I will point you in the direction of the mime-types. The Mozilla list of mime types just happens to include the most common extension as well.

Multiple extensions in one datatype

This is a question that most people without a doubt will ask. Is it possible to add multiple extensions inside a single datatype? Something like FileExt: “.png|.bmp|.jpg|.gif”. If we know that 4 different extensions define “picture files” – why have 4 different datatype files when one should be enough?

This is not supported, and with good reason. The whole point of a datatype file is to define a type as much as possible without actually doing a binary analysis. It may not matter to some people, but for others it is important to see the distinction between a png and jpg image file in the directory list.

So no, this is not supported. That would undermine and defeat the whole purpose.

Advertisements