Copyright | Copyright (C) 2004-2011 John Goerzen |
---|---|
License | BSD3 |
Maintainer | John Goerzen <jgoerzen@complete.org> |
Stability | provisional |
Portability | portable |
Safe Haskell | None |
Language | Haskell98 |
Utilities for guessing MIME types of files.
Written by John Goerzen, jgoerzen@complete.org
- 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 {}
- guessType :: MIMETypeData -> Bool -> String -> MIMEResults
- guessExtension :: MIMETypeData -> Bool -> String -> Maybe String
- guessAllExtensions :: MIMETypeData -> Bool -> String -> [String]
Creating Lookup Objects
defaultmtd :: MIMETypeData Source #
Default MIME type data to use
:: 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.
:: 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 #
MIMETypeData | |
|
:: MIMETypeData | Source data for guessing |
-> Bool | Whether to limit to strict data |
-> String | File or URL name to consider |
-> MIMEResults | Result of guessing (see |
Guess the type of a file given a filename or URL. The file is not opened; only the name is considered.
:: 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.
:: 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.