Trivial-Mimes
Author: Nicolas Hafner <shinmera@tymoon.eu>
Description: Tiny library to detect mime types in files.

## About Trivial-Mimes

This is a teensy library that provides some functions to determine the mime-type of a file. As I've had a need for this kind of functionality more than once now and haven't found any suitably lightweight alternative I quickly whipped this up.

## How To

    (mimes:mime #p"~/something.png")

Upon loading, trivial-mimes builds a mime-type database from the local `mime.types` file or a copy thereof from its own source directory. This database is a simple association of file extension to mime-type (see `mime-lookup`). If the mime lookup in the database fails, it will instead try to consult the `file` shell utility on unix systems (see `mime-probe`). If that too doesn't work, it falls back onto a default.

## Copyright

trivial-mimes is licensed under the Artistic license. © Nicolas Hafner <shinmera@tymoon.eu> . This library can be obtained on https://github.com/Shinmera/trivial-mimes.

## Package Index

- ### TRIVIAL-MIMES (ORG.TYMOONNEXT.TRIVIAL-MIMES MIMES)

  - special

    #### `*MIME-DB*`

        An EQUALP hash-table with file-extensions as keys and the mime-types as values.

  - function `(`

    #### `FIND-MIME.TYPES`

    `` ```)`

        Attempts to find a usable MIME.TYPES file.
        If none can be found, an error is signalled.

  - function `(`

    #### `MIME`

    `` `PATHNAME &OPTIONAL (DEFAULT "application/octet-stream")``)`

        Attempts to detect the mime-type of the given pathname.
        First uses MIME-LOOKUP, then MIME-PROBE and lastly returns the DEFAULT if both fail.

  - function `(`

    #### `MIME-FILE-TYPE`

    `` `MIME-TYPE``)`

        Returns a matching file-extension for the given mime-type.
        If the given mime-type cannot be found, NIL is returned.

  - function `(`

    #### `MIME-LOOKUP`

    `` `PATHNAME``)`

        Attempts to get the mime-type by file extension comparison.
        If none can be found, NIL is returned.

  - function `(`

    #### `MIME-PROBE`

    `` `PATHNAME``)`

        Attempts to get the mime-type through a call to the FILE shell utility.
        If the file does not exist or the platform is not unix, NIL is returned.