The trivial-mimes Reference Manual

Table of Contents

Next: , Previous: , Up: (dir)   [Contents][Index]

The trivial-mimes Reference Manual

This is the trivial-mimes Reference Manual, version 1.1.0, generated automatically by Declt version 2.4 "Will Decker" on Wed Jun 20 12:41:52 2018 GMT+0.


Next: , Previous: , Up: Top   [Contents][Index]

1 Introduction

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.


Next: , Previous: , Up: Top   [Contents][Index]

2 Systems

The main system appears first, followed by any subsystem dependency.


Previous: , Up: Systems   [Contents][Index]

2.1 trivial-mimes

Maintainer

Nicolas Hafner <shinmera@tymoon.eu>

Author

Nicolas Hafner <shinmera@tymoon.eu>

Home Page

https://github.com/Shinmera/trivial-mimes

License

Artistic

Description

Tiny library to detect mime types in files.

Version

1.1.0

Source

trivial-mimes.asd (file)

Component

mime-types.lisp (file)


Next: , Previous: , Up: Top   [Contents][Index]

3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Previous: , Up: Files   [Contents][Index]

3.1 Lisp


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.1 trivial-mimes.asd

Location

trivial-mimes.asd

Systems

trivial-mimes (system)


Previous: , Up: Lisp files   [Contents][Index]

3.1.2 trivial-mimes/mime-types.lisp

Parent

trivial-mimes (system)

Location

mime-types.lisp

Packages

trivial-mimes

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

4 Packages

Packages are listed by definition order.


Previous: , Up: Packages   [Contents][Index]

4.1 trivial-mimes

Source

mime-types.lisp (file)

Nicknames
Use List

common-lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Next: , Previous: , Up: Definitions   [Contents][Index]

5.1 Exported definitions


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.1 Special variables

Special Variable: *mime-db*

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

Package

trivial-mimes

Source

mime-types.lisp (file)


Previous: , Up: Exported definitions   [Contents][Index]

5.1.2 Functions

Function: find-mime.types ()

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

Package

trivial-mimes

Source

mime-types.lisp (file)

Function: mime PATHNAME &optional DEFAULT

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.

Package

trivial-mimes

Source

mime-types.lisp (file)

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.

Package

trivial-mimes

Source

mime-types.lisp (file)

Function: mime-lookup PATHNAME

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

Package

trivial-mimes

Source

mime-types.lisp (file)

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.

Package

trivial-mimes

Source

mime-types.lisp (file)


Previous: , Up: Definitions   [Contents][Index]

5.2 Internal definitions


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.1 Special variables

Special Variable: *reverse-mime-db*

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

Package

trivial-mimes

Source

mime-types.lisp (file)


Previous: , Up: Internal definitions   [Contents][Index]

5.2.2 Functions

Function: %read-tokens LINE
Package

trivial-mimes

Source

mime-types.lisp (file)

Function: build-mime-db &optional FILE

Populates the *MIME-DB* with data gathered from the file. The file should have the following structure:

MIME-TYPE FILE-EXTENSION*

Package

trivial-mimes

Source

mime-types.lisp (file)

Function: whitespace-p CHAR
Package

trivial-mimes

Source

mime-types.lisp (file)


Previous: , Up: Top   [Contents][Index]

Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts

Jump to:   F   L   T  
Index Entry  Section

F
File, Lisp, trivial-mimes.asd: The trivial-mimes<dot>asd file
File, Lisp, trivial-mimes/mime-types.lisp: The trivial-mimes/mime-types<dot>lisp file

L
Lisp File, trivial-mimes.asd: The trivial-mimes<dot>asd file
Lisp File, trivial-mimes/mime-types.lisp: The trivial-mimes/mime-types<dot>lisp file

T
trivial-mimes.asd: The trivial-mimes<dot>asd file
trivial-mimes/mime-types.lisp: The trivial-mimes/mime-types<dot>lisp file

Jump to:   F   L   T  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

Jump to:   %  
B   F   M   W  
Index Entry  Section

%
%read-tokens: Internal functions

B
build-mime-db: Internal functions

F
find-mime.types: Exported functions
Function, %read-tokens: Internal functions
Function, build-mime-db: Internal functions
Function, find-mime.types: Exported functions
Function, mime: Exported functions
Function, mime-file-type: Exported functions
Function, mime-lookup: Exported functions
Function, mime-probe: Exported functions
Function, whitespace-p: Internal functions

M
mime: Exported functions
mime-file-type: Exported functions
mime-lookup: Exported functions
mime-probe: Exported functions

W
whitespace-p: Internal functions

Jump to:   %  
B   F   M   W  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.3 Variables

Jump to:   *  
S  
Index Entry  Section

*
*mime-db*: Exported special variables
*reverse-mime-db*: Internal special variables

S
Special Variable, *mime-db*: Exported special variables
Special Variable, *reverse-mime-db*: Internal special variables

Jump to:   *  
S  

Previous: , Up: Indexes   [Contents][Index]

A.4 Data types

Jump to:   P   S   T  
Index Entry  Section

P
Package, trivial-mimes: The trivial-mimes package

S
System, trivial-mimes: The trivial-mimes system

T
trivial-mimes: The trivial-mimes system
trivial-mimes: The trivial-mimes package

Jump to:   P   S   T