MissingH-1.0.2.1: Large utility librarySource codeContentsIndex
Data.MIME.Types
Portabilityportable
Stabilityprovisional
MaintainerJohn Goerzen <jgoerzen@complete.org>
Contents
Creating Lookup Objects
Basic Access
Description

Utilities for guessing MIME types of files.

Written by John Goerzen, jgoerzen@complete.org

Synopsis
defaultmtd :: MIMETypeData
readMIMETypes :: MIMETypeData -> Bool -> FilePath -> IO MIMETypeData
hReadMIMETypes :: MIMETypeData -> Bool -> Handle -> IO MIMETypeData
readSystemMIMETypes :: MIMETypeData -> IO MIMETypeData
type MIMEResults = (Maybe String, Maybe String)
data MIMETypeData = MIMETypeData {
suffixMap :: Map String String
encodingsMap :: Map String String
typesMap :: Map String String
commonTypesMap :: Map String String
}
guessType :: MIMETypeData -> Bool -> String -> MIMEResults
guessExtension :: MIMETypeData -> Bool -> String -> Maybe String
guessAllExtensions :: MIMETypeData -> Bool -> String -> [String]
Creating Lookup Objects
defaultmtd :: MIMETypeDataSource
Default MIME type data to use
readMIMETypesSource
:: MIMETypeDataData to work with
-> BoolWhether to work on strict data
-> FilePathFile to read
-> IO MIMETypeDataNew object
Read the given mime.types file and add it to an existing object. Returns new object.
hReadMIMETypesSource
:: MIMETypeDataData to work with
-> BoolWhether to work on strict data
-> HandleHandle to read from
-> IO MIMETypeDataNew object
Load a mime.types file from an already-open handle.
readSystemMIMETypes :: MIMETypeData -> IO MIMETypeDataSource
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
suffixMap :: Map String StringA mapping used to expand common suffixes into equivolent, better-parsed versions. For instance, .tgz would expand into .tar.gz.
encodingsMap :: Map String StringA mapping used to determine the encoding of a file. This is used, for instance, to map .gz to gzip.
typesMap :: Map String StringA mapping used to map extensions to MIME types.
commonTypesMap :: Map String StringA mapping used to augment the typesMap when non-strict lookups are used.
guessTypeSource
:: MIMETypeDataSource data for guessing
-> BoolWhether to limit to strict data
-> StringFile or URL name to consider
-> MIMEResultsResult 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.
guessExtensionSource
:: MIMETypeDataSource data for guessing
-> BoolWhether to limit to strict data
-> StringMIME type to consider
-> Maybe StringResult 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.

guessAllExtensionsSource
:: MIMETypeDataSource data for guessing
-> BoolWhether to limit to strict data
-> StringMIME 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.
Produced by Haddock version 2.6.0