MissingH-1.4.1.0: Large utility library

CopyrightCopyright (C) 2004-2011 John Goerzen
LicenseBSD3
MaintainerJohn Goerzen <jgoerzen@complete.org>
Stabilityprovisional
Portabilityportable
Safe HaskellNone
LanguageHaskell98

Data.MIME.Types

Contents

Description

Utilities for guessing MIME types of files.

Written by John Goerzen, jgoerzen@complete.org

Synopsis

Creating Lookup Objects

defaultmtd :: MIMETypeData Source #

Default MIME type data to use

readMIMETypes Source #

Arguments

:: MIMETypeData

Data to work with

-> Bool

Whether to work on strict data

-> FilePath

File to read

-> IO MIMETypeData

New object

Read the given mime.types file and add it to an existing object. Returns new object.

hReadMIMETypes Source #

Arguments

:: MIMETypeData

Data to work with

-> Bool

Whether to work on strict data

-> Handle

Handle to read from

-> IO MIMETypeData

New object

Load a mime.types file from an already-open handle.

readSystemMIMETypes :: MIMETypeData -> IO MIMETypeData Source #

Read the system's default mime.types files, and add the data contained therein to the passed object, then return the new one.

Basic Access

type MIMEResults = (Maybe String, Maybe String) Source #

Return value from guessing a file's type.

The first element of the tuple gives the MIME type. It is Nothing if no suitable type could be found.

The second element gives the encoding. It is Nothing if there was no particular encoding for the file, or if no encoding could be found.

data MIMETypeData Source #

Constructors

MIMETypeData 

Fields

guessType Source #

Arguments

:: MIMETypeData

Source data for guessing

-> Bool

Whether to limit to strict data

-> String

File or URL name to consider

-> MIMEResults

Result of guessing (see MIMEResults for details on interpreting it)

Guess the type of a file given a filename or URL. The file is not opened; only the name is considered.

guessExtension Source #

Arguments

:: MIMETypeData

Source data for guessing

-> Bool

Whether to limit to strict data

-> String

MIME type to consider

-> Maybe String

Result of guessing, or Nothing if no match possible

Guess the extension of a file based on its MIME type. The return value includes the leading dot.

Returns Nothing if no extension could be found.

In the event that multiple possible extensions are available, one of them will be picked and returned. The logic to select one of these should be considered undefined.

guessAllExtensions Source #

Arguments

:: MIMETypeData

Source data for guessing

-> Bool

Whether to limit to strict data

-> String

MIME type to consider

-> [String]

Result of guessing

Similar to guessExtension, but returns a list of all possible matching extensions, or the empty list if there are no matches.