Gnome Library Reference Manual | |||
---|---|---|---|
<<< Previous Page | Home | Up | Next Page >>> |
#include <gnome.h> const char* gnome_mime_type (const |
The routines in gnome-mime provide a way to obtain the MIME (Multipurpose Internet Mail Extension) type of a given file and some utility functions.
There are two different methods for getting the MIME type of a particular file: Using only the filename to find the corresponding MIME type by matching the name against a database of known extensions and regular expressions; Or obtaining the MIME type by peeking at the contents of the file. Generally it should be faster using the former method, because the routines only do in-memory operations, while the latter method needs to do possibly time-expensive disk operations to obtain the necessary information.
The routines that classify a file only by its name, look at the *.mime files in the $gnome_prefix/share/mime-info/ directory and in ~/.gnome/mime-info/ to build the extension database. This gives the user the possibility to extend and/or override the system defaults.
Applications wanting to make additional MIME types available only need to install their files in one of these directories.
The file $gnome_prefix/share/mime-info/gnome.mime contains the defaults for Gnome and is read first. In addition, ~/.gnome/mime-info/user.mime is the last file to be read and thus makes it possible to set system-wide defaults and still gives the user a chance to override them. However, there is currently no determined order in which the other files in these directories will be read, nor is there any way to override system defaults, yet.
The gnome_mime_type_from_magic() function looks at the $gnome_prefix/etc/mime-magic file to determine the MIME type of a given file (This database in usually kept in a pre-processed, easily readable format in $gnome_prefix/etc/mime-magic.dat).
const char* gnome_mime_type (const |
Determined the mime type for filename.
const char* gnome_mime_type_or_default (const |
This routine tries to determine the mime-type of the filename only by looking at the filename from the GNOME database of mime-types.
const char* gnome_mime_type_of_file (const char *existing_filename); |
Determined the mime type for existing_filename. It will try to figure this out by looking at the contents of the file, if this fails it will use the filename to figure out a name.
const char* gnome_mime_type_or_default_of_file (const char *existing_filename, const |
This routine tries to determine the mime-type of the filename by trying to guess the content of the file. If this fails, it will return the mime-type based only on the filename.
const char* gnome_mime_type_from_magic (const |
This routine uses a magic database as described in magic(5) that maps files into their mime-type (so our modified magic database contains mime-types rather than textual descriptions of the files).
|
uri_list : | an uri-list in the standard format |
Returns : | a GList containing strings allocated with g_malloc that contain the filenames in the uri-list. Note that unlike gnome_uri_list_extract_uris() function, this will discard any non-file uri from the result value. |
void gnome_uri_list_free_strings ( |
Releases all of the resources allocated by list.
list : | A GList returned by gnome_uri_list_extract_uris() or gnome_uri_list_extract_filenames() |