This class allows the application to retrieve the information about all known
MIME types from a system-specific location and the filename extensions to the
MIME types and vice versa. After initialization the functions
MimeTypesManager#get_file_type_from_mime_type
and MimeTypesManager#get_file_type_from_extension
may be called: they will return a FileType object which
may be further queried for file description, icon and other attributes.
Windows: MIME type information is stored in the registry and no additional
initialization is needed.
Unix: MIME type information is stored in the files mailcap and mime.types
(system-wide) and .mailcap and .mime.types in the current user’s home directory:
all of these files can be searched for and loaded (disabled by default). However,
MimeTypesManager#read_mailcap and
MimeTypesManager#read_mime_types are
provided to load additional files.
If GNOME or KDE desktop environment is installed, then MimeTypesManager
gathers MIME information from respective files (e.g. .kdelnk files under KDE).
NB: Currently, MimeTypesManager is limited to reading MIME type information
but it will support modifying it as well in future versions.
Global instance of MimeTypesManager is always available. It is defined
as follows:
It is recommended to use this instance instead of creating your own because
gathering MIME information may take quite a long time on Unix systems.
No base class.
All of these functions are static (i.e. don’t need a MimeTypesManager object
to call them) and provide some useful operations for string representations of
MIME types. Their usage is recommended instead of directly working with MIME
types using String functions.
NB: You won’t normally need to use more than one MimeTypesManager object in a
program.
These functions are the heart of this class: they allow to find a file type object
from either file extension or MIME type.
If the function is successful, it returns a pointer to the FileType object
which must be deleted by the caller, otherwise NULL will be returned.
get_file_type_from_mime_type
get_file_type_from_extension
Unix: These functions may be used to load additional files (except for the
default ones which are loaded automatically) containing MIME
information in either mailcap(5) or mime.types(5) format.
read_mailcap
read_mime_types
add_fallbacks
This function may be used to provide hard-wired fallbacks for the MIME types
and extensions that might not be present in the system MIME database.
Please see the typetest sample for an example of using it.
Gather information about the files with given extension and return the
corresponding FileType object or NULL if the extension
is unknown.
Gather information about the files with given MIME type and return the
corresponding FileType object or NULL if the MIME type
is unknown.
This function returns true if either the given mimeType is exactly the
same as wildcard or if it has the same category and the subtype of
wildcard is ‘*’. Note that the ‘*’ wildcard is not allowed in
mimeType itself.
The comparison don by this function is case insensitive so it is not
necessary to convert the strings to the same case before calling it.
Load additional file containing information about MIME types and associated
information in mailcap format. See metamail(1) and mailcap(5) for more
information.
fallback parameter may be used to load additional mailcap files without
overriding the settings found in the standard files: normally, entries from
files loaded with ReadMailcap will override the entries from files loaded
previously (and the standard ones are loaded in the very beginning), but this
will not happen if this parameter is set to true (default is false).
The return value is true if there were no errors in the file or false
otherwise.
Load additional file containing information about MIME types and associated
information in mime.types file format. See metamail(1) and mailcap(5) for more
information.
The return value is true if there were no errors in the file or false
otherwise.
[This page automatically generated from the Textile source at 2023-06-03 08:07:31 +0000]