MimeCache

Class for reading mime.cache files. Mime cache is mainly optimized for MIME type detection by file name.

This class is somewhat low level and tricky to use directly. Also it knows nothing about mime.type.MimeType. Note: This class does not try to provide more information than the underlying mime.cache file has.

Constructors

this
this(string fileName)

Read mime cache from given file (usually mime.cache from one of mime paths) Note: File will be mapped into memory with MmFile. Warning: Strings returned from MimeCache can't be considered permanent and must be copied with dup or idup if their lifetime is longer than this object's one.

this
this(immutable(void)[] data, string fileName)

Read mime cache from given data.

Members

Functions

aliases
auto aliases()

MIME type aliases.

fileName
string fileName()

File name MimeCache was loaded from.

findGenericIcon
const(char)[] findGenericIcon(const(char)[] mimeType)

Find generic icon name for mime type.

findIcon
const(char)[] findIcon(const(char)[] mimeType)

Find icon name for mime type.

findMimeTypeByNamespaceURI
const(char)[] findMimeTypeByNamespaceURI(const(char)[] namespaceURI)
Undocumented in source. Be warned that the author may not have intended to support it.
findMimeTypesByData
auto findMimeTypesByData(const(void)[] data)

Find all MIME type alternatives for data matching it against magic rules.

findMimeTypesByGlob
auto findMimeTypesByGlob(const(char)[] fileName)

Find all MIME type alternatives for fileName using glob patterns which are not literals or suffices.

findMimeTypesByLiteral
auto findMimeTypesByLiteral(const(char)[] fileName)

Find all MIME type alternatives for fileName using literal patterns like Makefile.

findMimeTypesBySuffix
void findMimeTypesBySuffix(const(char)[] fileName, OutRange sink)

Find all MIME type alternatives for fileName using suffix patterns like *.cpp. Due to mime cache format characteristics it uses output range instead of returning the input one.

genericIcons
auto genericIcons()

Generic icons for MIME types.

globs
auto globs()

Glob patterns that are not literal nor suffixes.

icons
auto icons()

Icons for MIME types.

isSubclassOf
bool isSubclassOf(const(char)[] mimeType, const(char)[] parent)

Recursively check if mimeType is subclass of parent. Note: Mime type is not considered to be subclass of itself.

literals
auto literals()

Literal patterns.

magicMatches
auto magicMatches()

All magic matches in this mime cache. Matches don't include magic rules themselves, but they reference matchlets.

magicMatchlets
auto magicMatchlets(uint matchletCount, uint firstMatchletOffset)

One level magic matchlets. matchletCount and firstMatchletOffset should be taken from MatchEntry or upper level MatchletEntry.

magicToDelete
auto magicToDelete()

Names of mime types which magic rules from the least preferred mime.cache files should be discarded.

namespaces
auto namespaces()

XML namespaces for MIME types.

parents
auto parents(const(char)[] mimeType)

Get direct parents of given mimeType.

resolveAlias
const(char)[] resolveAlias(const(char)[] aliasName)

Resolve MIME type name by aliasName.

Meta