mime_types — Logtalk 3.100.1

object

# `mime_types`

MIME type registry and convenience predicates for mapping file names and URLs to media types.

Availability:
`logtalk_load(mime_types(loader))`
Author: Paulo Moura
Version: 1:1:0
Date: 2026-04-17
Compilation flags:
`static, context_switching_calls`
Uses:
list
os
reader
string(Representation)
Remarks:

> - Default behavior: Convenience predicates default to lenient lookup by consulting both built-in standard mappings and built-in common mappings.

> - Path decomposition: File path decomposition uses the `os` library `decompose_file_name/4` predicate.

> - External overlays: Additional `mime.types`-style files can be loaded into the in-memory registry using the `load/1-2` predicates.

Inherited public predicates:
(none)

## Public predicates

### `guess_type/3`

Guesses the MIME type and content encoding for a URL or file name using lenient lookup. Unknown values are returned as the empty atom.

Compilation flags:
`static`
Template:
`guess_type(Resource,Type,Encoding)`
Mode and number of proofs:
`guess_type(+atom,-atom,-atom)` - `one`

### `guess_type/4`

Guesses the MIME type and content encoding for a URL or file name. When `Strict` is `true`, only built-in standard mappings and strict runtime overlays are consulted.

Compilation flags:
`static`
Template:
`guess_type(Resource,Type,Encoding,Strict)`
Mode and number of proofs:
`guess_type(+atom,-atom,-atom,+boolean)` - `one`

### `guess_file_type/3`

Guesses the MIME type and content encoding for a file path using lenient lookup. Unknown values are returned as the empty atom.

Compilation flags:
`static`
Template:
`guess_file_type(Path,Type,Encoding)`
Mode and number of proofs:
`guess_file_type(+atom,-atom,-atom)` - `one`

### `guess_file_type/4`

Guesses the MIME type and content encoding for a file path.

Compilation flags:
`static`
Template:
`guess_file_type(Path,Type,Encoding,Strict)`
Mode and number of proofs:
`guess_file_type(+atom,-atom,-atom,+boolean)` - `one`

### `extension_type/2`

Returns the MIME type associated with a file extension using lenient lookup.

Compilation flags:
`static`
Template:
`extension_type(Extension,Type)`
Mode and number of proofs:
`extension_type(+atom,-atom)` - `zero_or_one`

### `extension_type/3`

Returns the MIME type associated with a file extension.

Compilation flags:
`static`
Template:
`extension_type(Extension,Type,Strict)`
Mode and number of proofs:
`extension_type(+atom,-atom,+boolean)` - `zero_or_one`

### `guess_extension/2`

Returns the preferred file extension associated with a MIME type using lenient lookup.

Compilation flags:
`static`
Template:
`guess_extension(Type,Extension)`
Mode and number of proofs:
`guess_extension(+atom,-atom)` - `zero_or_one`

### `guess_extension/3`

Returns the preferred file extension associated with a MIME type.

Compilation flags:
`static`
Template:
`guess_extension(Type,Extension,Strict)`
Mode and number of proofs:
`guess_extension(+atom,-atom,+boolean)` - `zero_or_one`

### `guess_all_extensions/2`

Returns all known file extensions associated with a MIME type using lenient lookup.

Compilation flags:
`static`
Template:
`guess_all_extensions(Type,Extensions)`
Mode and number of proofs:
`guess_all_extensions(+atom,-list(atom))` - `one`
`guess_all_extensions(+atom,-list(atom))` - `one`

### `guess_all_extensions/3`

Returns all known file extensions associated with a MIME type.

Compilation flags:
`static`
Template:
`guess_all_extensions(Type,Extensions,Strict)`

### `add_type/2`

Adds a lenient runtime mapping from a MIME type to a file extension.

Compilation flags:
`static`
Template:
`add_type(Type,Extension)`
Mode and number of proofs:
`add_type(+atom,+atom)` - `one`

### `add_type/3`

Adds a runtime mapping from a MIME type to a file extension.

Compilation flags:
`static`
Template:
`add_type(Type,Extension,Strict)`
Mode and number of proofs:
`add_type(+atom,+atom,+boolean)` - `one`

### `read_mime_types/2`

Reads a `mime.types`-style file returning a list of `Extension-Type` pairs.

Compilation flags:
`static`
Template:
`read_mime_types(File,Pairs)`
Mode and number of proofs:
`read_mime_types(+atom,-list(pair(atom,atom)))` - `one`

### `load/1`

Loads a `mime.types`-style file as a lenient runtime overlay.

Compilation flags:
`static`
Template:
`load(File)`
Mode and number of proofs:
`load(+atom)` - `one`

### `load/2`

Loads a `mime.types`-style file as a strict or lenient runtime overlay.

Compilation flags:
`static`
Template:
`load(File,Strict)`
Mode and number of proofs:
`load(+atom,+boolean)` - `one`

### `reset/0`

Clears all runtime MIME type overlays.

Compilation flags:
`static`
Mode and number of proofs:
`reset` - `one`

### `suffix_alias/2`

Returns suffix aliases used before splitting encoding and type suffixes.

Compilation flags:
`static`
Template:
`suffix_alias(Alias,Expanded)`
Mode and number of proofs:
`suffix_alias(?atom,?atom)` - `zero_or_more`

### `encoding_suffix/2`

Returns content-encoding suffix mappings.

Compilation flags:
`static`
Template:
`encoding_suffix(Extension,Encoding)`
Mode and number of proofs:
`encoding_suffix(?atom,?atom)` - `zero_or_more`

## Protected predicates

(no local declarations; see entity ancestors if any)

## Private predicates

### `runtime_type_/3`

Table of runtime MIME type overlays.

Compilation flags:
`dynamic`
Template:
`runtime_type_(Strict,Extension,Type)`
Mode and number of proofs:
`runtime_type_(?boolean,?atom,?atom)` - `zero_or_more`

## Operators

(none)